Refactored to coffeescript and to use jQuery.Deferred()

instead of callbacks