Improved export.py