clean-up some of the global vars handling