Added utility functions for handling of timeouts and cancellations.