A surprise to no one, Boeing [BA] on Wednesday swung to a loss in its second quarter on massive charges related to its 737 commercial aircraft program, which also led to a precipitous decline in sales, but the negatives were partially offset by gains in the company’s defense and services businesses.

“The safe return to service of the 737 MAX is our company’s top priority,” Dennis Muilenburg, Boeing’s chairman, president and CEO, said on the company’s earnings call, repeating a statement he made during, and since, the company’s first quarter call in April.

Regulatory authorities and airlines worldwide have grounded the fleet of 737 MAX aircraft until Boeing can complete fixes that caused two catastrophic crashes last year and earlier this year. The company also is making software updates unrelated to the sensor issues that caused the crashes.

The net loss in the quarter was $2.9 billion, $5.21 earnings per share (EPS), from $2.2 billion ($3.73 EPS) in net income a year ago, but still beat consensus estimates that anticipated a loss of $6.69 per share. Last week Boeing said it would take a $4.9 billion ($8.74 EPS) after-tax charge in the second quarter related to its estimate of potential costs of the 737 MAX grounding and delivery delays.

Sales slid 35 percent to $15.8 billion from $24.3 billion a year ago as the 737 MAX charge lopped $5.6 billion from the topline and the company delivered less than half the commercial aircraft than it did a year ago.

Boeing’s defense business delivered strong results, with sales up 8 percent to $6.6 billion on higher volume for aircraft, satellites and weapons, while operating income rose 159 percent to $975 million on a property sale and lower cost growth on the Air Force KC-46 refueling tanker.

The real estate sale is part of ongoing affordability initiatives to “optimize our footprint and productivity,” Greg Smith, Boeing’s chief financial officer, said on the call.

Boeing Global Services reported an 11 percent increase in sales to $4.5 billion due to an acquisition and an increase in international government services work, and operating income rose 14 percent to $687 million on the sales growth.

Sales at the commercial aircraft segment dove 66 percent to $4.7 billion on a 54 percent decline in aircraft deliveries and the MAX charge, and the operating loss was $5 billion.

The company’s earnings call was dominated by questions about the MAX and other commercial aircraft programs. Boeing suspended its earnings guidance earlier this year due to the MAX issues and will update its outlook once it has clarity.

Total backlog at the end of the quarter stood at $474.3 billion, down from $490.5 billion at the end of 2018. Defense backlog stood at $63.9 billion, up from $61.3 billion in December, and the business took in $4 billion in orders. Of the current backlog, 31 percent of is from international customers.

Free cash in the quarter was an outflow of $1 billion. Despite the financial challenges stemming from the 737 woes, Boeing paid its shareholders $1.2 billion in dividends.