Refactored some code. Finished test suite.