Implemented some unit tests. Tweaked GUI and refactored code.