Cleanup
Cleanup
Major refactoring.  Added unit tests.