Fix crash condition in scheduler (take 1)