Rewrite most parts of the plugin to allow new features.
Mostly for #2 and for #8 and a little bit of work for #10.