Fix assertion in patch creation