tidy up agent and add plugins class