Refactored a lot of items and cleaned up tests.