Support cancellation of async operations

Adds support for passing cancellation tokens to all the asynchronous operations I could find.