[github-354] Add extra methods to StringUtil and refactor some code to use them. Thanks to XenoAmess. This closes #354