Bugfix/71 improve dumping attachments backport

Proper PR for backporting this fix to release 4.2.
Issue #71