cleaned up some code and tests