Minor Code improvements
Imporved global variables