Major CoffeeScript refactoring