Update to using fresh stdlib string functions, remove local duplicates.