major rewrite: improved plugin system