Sorry but I don't know the cause of the problem you are having with your custom code (i've never seen your code and I am not a mind reader) so I can offer no help. I do not have time to help everyone with their customizations, I have my own work to do. If some easy solution to your question would come to mind I would help, but this time no solution occurs to me and I have no time to investigate it.
Best,
Joe