Hostess Brands Inc. can breathe a little easier now. The Twinkie maker got a little help from a judge yesterday when it was given the green light to reject certain union contracts and modify some retiree benefits as it attempts to extract itself from the vat of Fruit Pie filling that is the privately held company’s second bankruptcy.

Bankruptcy Judge Robert Drain said Hostess will be allowed to reject agreements with the Bakery, Confectionery, Tobacco Workers and Grain Millers International Union (BCTGM). Judge Drain also noted, however, that Hostess cannot modify or reject contracts that had expired prior to the start of the hearing, under which the union is still operating. Because of this, certain employees or pensioners can retain some benefits included in their expired contracts.

Hostess and BCTGM had been haggling over the expiration date of some of the agreements, and a hearing will occur on May 16 to determine the validity of those contested agreements.

The company was forced to file for Chapter 11 bankruptcy protection in January, just two years after emerging from its last filing, as it struggles to shed legacy costs associated with its pension plans and massive debt levels.

Hostess says that these steps are needed to raise capital to get the company back on track. It runs about 36 bakeries and employs around 19,000 people, many of whom are members of 12 unions.

Interstate Bakeries, Hostess’ former name, filed for Chapter 11 in 2004 and emerged in 2009. Hostess said that the changes it made during its previous bankruptcy proved insufficient, and that it owes its biggest unsecured creditor, Bakery & Confectionery Union & Industry International Pension Fund, $944.2 million. It also owes its second-biggest unsecured creditor, Central States, Southeast and Southwest Areas Pension Plan about $11.8 million.

Hostess CEO Brian Driscoll said in January that the company is working with its unions to modify its collective bargaining agreements, and that the company will maintain routine operations via a $75 million financing commitment from investment firm Silver Point Capital.

He also said that the company plans to restructure into a “strong, competitive” company. “This company has tremendous potential if we can remove the barriers to success,” Driscoll said.

For more on Hostess and BCTGM, read Reuters.

For InsideCounsel’s previous coverage of the Hostess bankruptcy, read:

Hostess files for bankruptcy … again