ABSTRACT_STRING.replacing: cleanup and test, plus a memory-friendly version