Removed a bunch of functions and vars out of global.