Fix timeout sleep handling to track time more accurately