Fixed RST generation, perform better error checking on corrupt files