Refactored code somewhat and moved to coffee, added write tests.