Refactor moar. Remove more global state.