Plugin o rama

General improvements to the plugin support.

This is #1189 

Ready for review AFAICS.