added changes in sched.c (with sergei)