Fix a bunch of scheduler bug!.