Rewrite most of the python code for the plugin.