More efficient string-flatten