Reorder some #includes

Deal with INT64_C conflicts between <stdint.h> and sim_defs.h

Free parsebuf when closing a pdf handle.