Large-scale rewrite of the plugin.

The manner in which the "update" handler creates and adds <optgroup> and <option> elements has been rewritten. There are also changes to the "init" handler.