Got rid of some unnecessary data in memory, and cleaned up some code