Various fixes to ensure that state machines exit when pools are idle & out of input. Also add some debug-only output.