Cleanup and compatibility changes.

Add head doc with copyright and license info. Encapsulate plugin
functions so they don't clash with other loaded plugins. Add double
inclusion guard and a guard against 'compatible' mode use.