Improved export code