I don't know the exact issue, but I think I have an idea of where to look: I believe there's an issue with variables used for character names. Some characters don't have names but should, some have repeated names, and some use the wrong name variable in the text.
I know you said you are a programmer (and I am not), so it seems odd that it would be this simple to solve, but... it almost seems like you have a single variable repeatedly being reassigned new values instead of a new variable being generated.