Heavily refactored the plugin. Removed threads and much of complexity. More cleaning of code possible.