refactored plugin code structure and js interface