Refactor request cancellation.