Start implementing the plugin system, plus add some tests.