Cleaned up code, added some documentation, and added tests that dont work.