Changed ugly custom chaining model to jQuery deferred classes.