Cleaned up some code and started working on tests