some refactoring in plugin structure