Refactored wait() into WaitingDeferred.wait().