Completed first basic implementation, now working on unit tests.
Did some small refactoring.