Re-write / reboot

Hey Rob - this is a fairly extensive rewrite of your original plugin, so do take a copy of your local files (or view on another branch) if you decide to merge this request!

Lots of info and comments in the list of commits below...

Please do come back to me with comments/questions.

Al