Fix delay implementation to support cancellation