Scheduler code cleanup/rewrite
Core rewrite, scratch priority support