more robust exporting, fixes #716
Merge branch 'pr721'