Fix a NPE, and add a couple of helper functions in Deferred