Updated plugin - bugfixes, refactoring