bug 2098: implement patch applying logic on master side. Work in progress