More error checks and faster pdf download