Moved most globals to g