As in most debugging efforts, a better approach than guessing/hacking is to find out what the problem is.
- create a reproducible example
- go to a part in your code where the problem manifests itself
- examine the data coming into that code, and the data going out of that code.
- the problem then is IN the code you're looking at, before that section, or after that section.
Follow the data and values. IF your starting values/data are good, find a place where it's bad. The problem is in-between.
Just FYI, the chances of posting a general description of a problem and someone posting "I had exactly the same problem. Change x=5 to x=6," are extremely unlikely.