Fix a potential crash in Scheduler