Fix integer overflow in scheduling.