Clean up and convert to Coffeescript