NPC International said Thursday Flynn Restaurant Group and Wendy’s reached an agreement after mediation to split the purchase of NPC’s nearly 400 bankrupt Wendy’s stores as part of an $801 million deal.

According to court documents, Flynn would acquire Wendy’s stores in the Salt Lake City, Central Maryland, Baltimore North, and Baltimore South markets, more than 925 Pizza Hut restaurants, and all of the franchisee’s shared service assets for $552.6 million. Five Wendy’s franchisees that were previously joined in a consortium bid would acquire stores in the Kansas City Business, North Greensboro Business, South Greensboro Business, and Raleigh Business markets for $248.3 million. Wendy’s said it doesn’t expect to acquire and operate any stores as part of the transaction.

A hearing to approve the sale is scheduled for January 15. Wendy’s said it expects the sale to be completed by Q2. Both Wendy’s and Flynn have agreed to offer positions to all of NPC’s restaurant field operations employees and substantially all other non-field employees.

If the deal is finalized, Flynn—already the largest restaurant franchisee in the U.S.—would operate more than 2,500 stores across Applebee’s, Panera, Taco Bell, Arby’s, Pizza Hut, and Wendy’s.

“Flynn Restaurant Group has built our business over the last twenty plus years by focusing on managing superior operations with great teams of people at premier restaurant concepts,” said Greg Flynn, founder, chairman, and CEO of Flynn, in a statement. “The Pizza Hut and Wendy’s restaurants we have agreed to acquire from NPC align perfectly with this strategy, and we’re confident that our new team members will fit right in at Flynn Restaurant Group.”

NPC filed for bankruptcy in July and later designated Flynn as the stalking horse bidder. The purchase agreement was valued at $816 million.

Prior to the auction, Wendy’s cited several objections and refused to give Flynn consent to operate its restaurants. Those complaints included Flynn’s breakup fee, or funds that would be owed to the franchisee if it didn’t win the bid, as well as its ownership of Arby’s and Panera, which are competitors, according to the fast-food chain. Wendy’s and Flynn also couldn’t reach a final agreement on personal guarantees, reimaging and development obligations, store count limitations, or maximum leverage requirements.

Flynn called the issues solvable, but also argued that Wendy’s has allowed other franchisees to operate Arby’s and Panera units and noted more than 363 of NPC’s franchise agreements don’t name Arby’s or Panera as competitors. In addition, the franchisee agreed to invest significant capital in both brands.

Auctions were scheduled for the Wendy’s assets, Pizza Hut assets, and the combined assets, but each event was canceled. It was later announced that Flynn and Wendy’s had reached an impasse, and would enter mediation.

“This is an excellent outcome for NPC’s Wendy’s restaurants and our team,” said Carl Hauch, CEO and president of NPC’s Wendy’s division, in a statement. “We are very pleased that our restaurants will be joining the ranks of established, high performing restaurant franchise groups. We are grateful to Judge Isgur for his guidance during the mediation process and to Wendy’s, Flynn, the Wendy’s franchisee acquirers and our lenders for working diligently to allow for this result.”

Fast Food, Finance, Story, Pizza Hut, Wendy's