Simplified the plugin and major refactoring