Got rid of more global variables.