That's way too much code for us to wade through. I suggest throwing together an SSCCE that demonstrates the problem, that way we can copy and paste your program to easily see what you're talking...