Refactor some of the operations in <string> so that they can be reused; no functionality change