refactor the coffeescript a bit more. Hopefully to resolve Jasmine failures