Several fixes to AgentPlayer and flow.