Boeing [BA] on Wednesday reported a smaller net loss in its fourth quarter as losses in its commercial aircraft segment and higher tax expenses more than offset a swing to profit in the defense business and a handsome gain in the services segment.

Still, the company generated $3.1 billion in free cash flow, marking the second straight quarter of positive cash flow, which is currently Boeing’s key financial metric. For 2022, free cash flow was $2.3 billion, the first positive cash flow since 2018.

Boeing reiterated its long-term financial outlook provided at an investor day last November with sales expected to reach $100 billion in the 2025 to 2026 timeframe, operating margins of around 10 percent, and free cash flow of about $10 billion. Boeing didn’t provide detailed guidance for 2023 but does expect between $3 billion and $5 billion in free cash flow.

The net loss in the quarter narrowed to $663 million, $1.06 earnings per share (EPS), from $4.2 billion ($7.02 EPS) a year ago. Excluding pension adjustments, the core operating loss in the quarter was $1.75 per share versus consensus estimates the company would post a 20 cents EPS core profit.

The swing to operating profit in the defense segment was tempered by ongoing “supply chain constraints and labor instability,” Brian West, Boeing’s chief financial officer, said on an earnings call. As supply chain issues lessen, operating margin in the defense business will increase, some of which is expected in 2023, he said.

Sales in the quarter increased 35 percent to $20 billion from $14.8 billion a year ago primarily on the back of the Commercial Airplanes segment, which benefited from a large jump in aircraft deliveries, and to a lesser extent on mid-single digit growth in the services and defense segments. The Global Services segment benefited from the continuing recovery in commercial airline travel while government-related business was soft.

Overall, in 2022 the company’s net loss widened to $5.1 billion ($8.30 EPS) from $4.3 billion ($7.15 EPS) in 2021 due to a bevy of previously reported charges on a number of defense programs during the year. Boeing Global Services was the only segment with positive operating income, which was up in 2022, while losses narrowed at Commercial Airlines, and widened at Defense, Space & Security on the charges.

Backlog at the end of 2022 stood at $404.4 billion, up 7 percent from $377.5 billion a year ago. Defense backlog fell 9 percent to $54.4 billion at the end of 2022 from $59.8 billion in 2021. International orders account for 28 percent of backlog entering 2023.