Have you tried stepping through the code with a debugger? Once you do that, if you are still stuck, I would try to narrow down the problem. It is unlikely anyone is going to look through your 200 lines of code. If you can hardcode values into the program to get it into the last state you think it is correct, then you can ask a much more direct question. However, if you prepare the question correctly it is likely you will find your own answer :)