Misc fixes for corrupted PDFs