Why/when is this needed? This seems unrelated to PDF attachments. If it is indeed, please move it into a separate commit.