Fix the scheduler bugs