re-worked control flow for agents.  Probably provisional