fix attachments, output pretty JSON