Fix smart-apply-patch bug