Refactored and cleaned up a bit. Down to 3 failing tests.