Cancellation support and improved error handling