You're not expecting somebody to look at all this code, are you?
Try to reduce the surface, or nobody will reasonably help you.
Take a look at the article linked in my signature line and find out a better way to post your questions.
-- Gianluca Sartori