Tweaked Tyilo's improvements to export script