improved handling of corrupt files