THE day after last June’s Brexit referendum, shares in British banks tanked. Most economists feared financial instability and recession, and few investors wanted to be associated with a sector that had been so badly damaged by the financial crisis (see chart). But eight months on the banks are doing better than expected. By recent standards, at least, their results have not been that bad. In 2016 Barclays avoided making a loss. And on February 22nd Lloyds, now almost exclusively a Britain-focused bank, posted its highest pre-tax profits for a decade. As in other countries, since the referendum banks’ share prices have outperformed the rest of the market.

How to explain this? A strong economy has supported banks’ revenues. Defying predictions, GDP growth in the second half of 2016 was faster than in the first. Unemployment has edged down. Fears of a wave of defaulting customers have not materialised: in the owner-occupied and buy-to-let sectors the share of mortgages in arrears is at a historic low.

Meanwhile, looser monetary policy in the wake of the Brexit vote has not done as much damage as some had predicted. The worry had been that the cut in interest rates in August from 0.5% to 0.25% would dent bank profitability by squeezing the margins between borrowing and lending rates. In fact the Bank of England is now in effect supporting such margins through its “term funding scheme”, which channels ultra-cheap money to institutions that lend more to customers, says Tony Yates of Birmingham University.

The cost of cleaning up for past misdeeds has in recent years eaten away at banks’ profits. But the end is now in sight. In 2016 Lloyds set aside £1bn ($1.2bn) for claims relating to mis-sold payment-protection insurance (PPI), a quarter of the previous year’s amount. In November overall PPI payouts were about 40% lower than a year earlier, according to the Financial Conduct Authority, a regulator. Analysts at Deutsche Bank reckon that British banks’ PPI liabilities will be fairly low in the coming year; 2019 may mark the deadline for claiming compensation.

One-off charges, however, remain a curse for Royal Bank of Scotland (RBS). On February 24th it reported a loss of £7bn in 2016. The bank insists that its core business is now healthy. Yet American regulatory bodies have accused it of mis-selling mortgage-backed securities, and the bank has set aside billions to settle the claims. The cost of righting past misdeeds may be even higher in 2017. Unsurprisingly, RBS’s shares have had a poor year.

That is bad news for British taxpayers, who have a £40bn stake in RBS after it was taken into public ownership during the financial crisis. That adds perhaps 2% of GDP to the national debt. With a budget looming on March 8th, the government is desperate to reduce its debt pile. But it will be some time before it can entirely privatise RBS (as it has almost done with Lloyds, which was also bailed out). After taking account of the cost of financing the bail-out, RBS’s share price must roughly double for the government to recoup what it put in. Britain’s banks may be beating expectations, but they are a long way from being fighting fit.