more robust exporting, fixes #716