Refactor string functions, fix many defects.

Is it worth a note saying it should be used for RDM and similar, for normal string copying use strncpy?