--fixed a few changes in global variable access inside functions