Improve remaining time calculation (so that it handles the case where it has looped around).