Moved scheduler-related code to sched.c.
Removed unused code.