Got rid of global vars.