Fixed bugs in scheduling.