Lots of changes to sched.c