Rewritten with abstraction.
Fixed an NPE in main.ms.
Replaced much PluginInternalException by NotFoundException.