Boeing [BA] on Tuesday reported higher sales and lower losses in the third quarter due to increased commercial aircraft deliveries and commercial services work.

Boeing’s defense segment posted weak results with operating income down significantly due to a $185 million charge related to NASA’s human spaceflight program to transport crews to the International Space Station.

Sales in the Defense, Space and Security segment fell 3 percent to $6.6 billion and operating income tumbled 31 percent to $436 million, mostly due to the charge, which stems from Boeing having to conduct a second orbital flight test of its Starliner Commercial Crew reusable spacecraft sometime in 2022 and to complete remaining work.

Backlog in the defense segment at the end of the quarter stood at $58 billion, down 5 percent from $61 billion at the end of 2020. International business accounts for 33 percent of the backlog.

The overall net loss of $132 million, 19 cents earnings per share (EPS), in the quarter shrank from a $466 million (79 cents EPS) loss a year ago. Adjusted earnings, which include certain pension impacts, were a loss of 60 cents EPS, 40 cents worse than analysts’ expectations.

The quarterly results differ from the second quarter, reported in July, when Boeing swung to net income of $567 million versus a $2.4 billion loss in the same period in 2020 due largely to the ongoing rebound in its Commercial Airplanes segment, which is benefiting from improving domestic air travel in the U.S. and elsewhere.

Sales in the quarter increased 8 percent to $15.3 billion from $14.1 billion a year ago.

The company hasn’t been providing its financial outlook following two fatal crashes of its 737 MAX passenger jet in late 2018 and early 2019.

The Commercial Airplanes segment benefited from higher 737 MAX deliveries, which were partially offset by no deliveries of its 787 airplane, which remains in limited production but isn’t being delivered to customers until quality issues are ironed out. The additional work on the 787 resulted in $183 million in “abnormal costs” in the quarter and are expected to eventually total $1 billion, Boeing said.

Boeing is currently building 19 737 MAX aircraft per month and is progressing toward 31 a month early in 2022. Taking production higher will depend on supply chain issues related to raw materials, logistics and labor availability, Dave Calhoun, Boeing’s president and CEO, said on the company’s earnings call. He said that “by the second half of next year, our industry will be supply constrained.”

Commercial Airplane sales increased 24 percent to $4.5 billion and the operating loss narrowed to $693 million from $1.4 billion a year ago.

Boeing’s Global Services segment boasted increases in sales and operating income, with revenue up 14 percent to $4.2 billion and profit up 138 percent to $644 million on the recovery in the commercial airline markets.

Free cash in the quarter was a $507 million outflow versus a $5.1 billion outflow a year ago and benefited from a $1.3 billion tax refund. Boeing is still forecasting a return to positive cash flow in 2022, Brian West, the company’s chief financial officer, said on the earnings call.

Total backlog at the end of the quarter stood at $367 billion, up about $3.5 billion since the end of 2020.