Refactored, fixed logger, add tests.