integrate basics of the plugin system, and do a bit of source code clean up