attachments rewrite patch fix