Add basic factory functionality
Replace the plugin object with a constructor function