FRANKFURT, Nov 9 (Reuters) - Commerzbank swung to a net profit in the third quarter despite weak markets as the German lender focuses on a major overhaul.

The 472 million euro ($547.7 million) net profit at Germany’s second-largest lender after Deutsche Bank was broadly in line with analysts’ expectations for a profit of 477 million euros, according to a Reuters poll of banks and brokerages.

The profit, which compares with a loss of 637 million euros in the second quarter and 288 million euros a year ago, comes as the bank goes through a major restructuring to increase profitability.

It is reducing its staff to 36,000 by 2020 from 43,000 at the end of 2015. The bank has also been focusing on digitising its back office and expanding its retail customer base.

“We have made good progress in laying foundations for our transformation this year,” Chief Executive Martin Zielke said in a statement on Thursday. “In the interest of sustainable long-term profitability, we are focussing on growth. We have grown both in terms of clients and assets.”

The bank reiterated that it was still expecting to eke out a “slightly positive” net profit for the full year of 2017.

In a sign of the bank’s improving financial health, its Common Equity Tier 1 capital ratio rose to 13.5 percent from 13 percent at the end of the second quarter.