convert attachment to a struct
try to clean up
allow inlining of attachments