manual merge of string fixes, needs another pass for exception safety but this should be safer than what was here