Got rid of a few global variables