Complete rewrite of scheduling system, minor cosmetic changes