Refactored codebase and tests for simplicity. Added more tests.