First pass at cleaning things up
Further cleanups
A few more...
Final fixes to make tests pass