Make cancelling and rescheduling of functions O(1)