Refactored save and export.