Added support for cancellation.