add support for optional patches

update #2468