Updated main to Coffeescript, refactored.