refactoring, deleting dead code, alignment to newer plugin API