Added JQuery deferred objects support. Updating to return promises