refactor plugins infrastructure