fixed some bugs where one substitution ate too much insertions and the next had no left. Also fixed the error code locations to match what is actually happening