Refactored the export plugin a bit, so it's easier to subclass.