Fixing the plugin system

A proposal. See #1