Eliminate global variables
Remove a number of globals that are not needed