Removed a bunch of redundant code in formatAttachments.