Maybe those globals are already used elsewhere and you are corrupting them? Without seeing the script or seeing any error message you may be getting I can't really do more than guess.
Best advice is don't use global variables without appending the name of the script to them and the g_ bit in front, that way you can be pretty sure they are unique.
Been there, done that, got all the T-Shirts!