Rewrite the scheduler in an agent-centric way

This seems to perform better than the old one.
If we want DEBUG here, could we read an environment variable to turn it on or off?