Some refactoring and cleaning, string utils.