Correct bug in string_gen that caused missing keys to misplace insertions