refactor the plugin a little to allow it to be properly initialised