Got rid of stupid globals
More cleanups