I suggest boiling the code down to an SSCCE to narrow the problem down to the minimal amount of code. There is a lot of code to wade through (and please use the code tags).