Fixing up exporting logic

now using id instead of date. much more robust, fixes #601