Fixing up exporting logic

now using id instead of date. much more robust, fixes #601
added some logic to not update last export inappropriately
Merge pull request #635 from ebensing/exporting

Fixing up exporting logic