Fix bugs in collectSchedule.