Make patch reading and writing less exception-prone.