Moved plugin code into its own class