Clean up plugins.py a bit