Refactor string functions, fix many defects.

No need.