Unfortunately I can't post a shortened version of the problem, as it seems related to the structure of the code. However, the problem appears rather on surface, at interface level and a quick look at line 158 and previous will make the question clear enough I hope.