Refactoring the data structures in agent.