Refactoring of Attachment constructor.