Refactored some CoffeeScript code to use classes