plugins: Split into a module loading library and class-based plugins

This is to address problems with the existing system (mainly that plugins are global)