refactored a whole bunch of things.