Cleaning up some code and fixing a few tests from last night