What you've said here points to the data you're pulling back from the server, and not from the actual infopath form itself.
The reason I say that is because it works the first few times, and you've compared the code from when it works and when it stop working, and it's all the same... so the *only* thing which has changed is the data, right?
You can test out the theory by removing all your entries from the document library - the form will probably start working again.
If that happens, use it till it breaks again, and then look at the very first entry in your default view on the library. There's probably something wrong with it, so the next trick will be to find out why.
One possibility is that another user has an old version of the template and is submitting bad data.