Deleted unused code, cleaned up existing code, added tests.