Some performance tweaks to the string functions