Refactor string functions, fix many defects.

Fair enough, although I believe in the rest of the codebase we fully qualify the namespace or use using.