OK - noticed a few oddities.

Instead of undo enable/disable, wrap the plugin code with gimp_image_undo_group_start and gimp_image_undo_group_end. THis will let you "undo" the plugin as one step, as it is now I can't undo the plugin.

You also leave a layer mask selected at the end. It is nicer to leave a layer selected.

An option to both merge visible and delete non-visible layers might be useful.

-Rob A>