Cleaning up/out code and adding some comments. Getting ready for tests.