Reorg agentx code