further refactor of plugin system