Made elapsed time in scheduleTimedTask cap out at dur.