Cleaned up the code. Added tests. Refactored setup task.