Added unit testing, refactored a bunch.