Rewritten scheduling system from scratch.