Rev 9170 from trunk: fix bug with looping in schedule()