Refactored main js to coffeescript