Made a few organization changes and added some unit tests.