various refactor made to uniform agents, and to make possible restart of a plugin