Fix parsing of various patch edge cases.