ON A plot next to the ultra-modern parliament building in Lilongwe is a shrine to Hastings Kamuzu Banda, who ruled Malawi for its first 33 years after independence from Britain. Baskets of flowers line the steps leading up to a replica of his tomb. The mausoleum is watched over by a portrait from around the time, in 1971, when he declared himself president for life. It shows him in a smart suit and tie, holding a fly-whisk.

Hastings Banda’s spectre also seemed to haunt Malawi’s elections held on May 20th. In a tight first-past-the-post race, each of the four main presidential candidates could trace a line to him. The youngest, Atupele Muluzi, is a son of Bakili Muluzi, who served in Hastings Banda’s cabinet and defeated him in elections in 1994. Peter Mutharika is the brother of Bingu Mutharika, who was Bakili Muluzi’s handpicked successor. Joyce Banda (no relation of the old man) was Bingu’s vice-president, succeeding him as president on his death in 2012; by then they had fallen out and she had formed a rival People’s Party. Lazarus Chakwera, a pastor, was the candidate of the Malawi Congress Party, Hastings Banda’s own outfit. As The Economist went to press, the result was too close to call. Early indications put Mr Mutharika and Mr Chakwera ahead of the incumbent.

Ms Banda, Africa’s second female president after Liberia’s Ellen Johnson Sirleaf, at first won plaudits from the West for her economic reforms. The kwacha had been fixed at a rate that was above its true value and led to shortages of foreign exchange with which to buy fuel and essentials. Ms Banda let it fall (there are now 395 kwacha to an American dollar) and phased out costly fuel subsidies at the same time. As the shortages eased, the economy recovered. Foreign aid began to flow back. GDP growth rose by 2% in 2012 to 5% last year.

Much of this good work was undone by a corruption scandal that came into the open in September. Sacks of cash were found in the cars of civil servants and in their newly built homes. It soon transpired that billions of kwacha had been looted from the state in a fraud, known as “Cashgate”, which involved hacking into government accounts and making bogus payments to shell firms. Foreign support for Malawi’s budget was suspended; donors would not put money into a leaky pot.

Ms Banda claimed the scam began before she was president. It probably did, but the tempo of theft seemed to speed up on her watch. A report in February by Baker Tilly, a British accountancy firm, found that the state was defrauded of $32m between April and September last year, equivalent to almost 1% of annual GDP.

Her opponents charged that the Cashgate loot was intended to finance the election campaign of her party. The scandal seems to have cost her votes in the big cities, Lilongwe and Blantyre, the commercial capital. Yet of her three challengers only Mr Chakwera, a preacher-turned-politician, has a strong claim to have no association with past misdeeds. The familiar names on the ballot sheet expose the thinness of Malawi’s elite. Only a few thousand, in a population of 16m, graduate from university every year. The big employers are government and aid agencies.

Malawi is a tough place to do business. It is ranked 171 out of 189 countries by the World Bank. The $500m invested in a uranium mine by Paladin Energy, an Australian company, was a rare example of a big foreign investment. The plant is now mothballed because a collapse in the price of uranium meant its revenues could not match the high cost of mining in Malawi.

Whoever is confirmed as president faces immediate challenges. The aid dollars chased away by Cashgate have shrunk the budget. Unpaid bills are piling up. The population is expanding by more than 3% a year, so rapid economic growth is needed just for living standards to stand still.

Two windfalls may help. The Millennium Challenge Corporation, an aid agency backed by the American government, is spending $350m to fix Malawi’s electricity. Vale, a Brazilian mining firm, is building a railway from Beira, in Mozambique, that juts into Malawi. The new president has at least some foundations to build on.