Simply never (I am repeating never) write long code. I suggest you to rewrite your code step by step testing every small snip of code. Even after adding only one statement to a program always compile and execute it.
Why do we must to investigate your too long code instead of you? It is your personal problem of a programmer.