Mogadishu — At Mogadishu's port, battered trucks without headlights and windscreens are piled with sacks and tyres, and parked beside a ship from the Comoros islands. Workers clamber on to crooked cabs to strap orange tarpaulins over the loads.
The port is busy, says its deputy manager Ahmed Abdi Karie. Food, vehicles and construction materials are coming in, and leather and lemons are going out. "In the last five months, construction materials account for most [imports] after food," he said.
Mogadishu is enjoying something of a boom after more than two decades of chaos following the fall of the dictator Mohamed Siad Barre in 1991.
Feuding warlords made the city their playground before the rise of the Islamist insurgents of al-Shabaab around 2006.
Now, 10 months after the rebels were pushed out of the city by African Union Mission in Somalia (Amisom) forces, Mogadishu's residents are rebuilding lives shattered by years of war and last year's famine.
"Mogadishu is open for business," said Kilian Kleinschmidt, the UN's deputy humanitarian co-ordinator. Somalis are returning from abroad to invest, shops are opening and the property market is booming. New buildings painted in cheerful pastels are rising out of the rubble, car washes service SUVs, and people are staying out late to shop, work or sit in cafes.
But this is a tale of two cities. During last year's drought and famine, hundreds of thousands of people poured into Mogadishu. Around 200,000 still live in flimsy shelters on rubbish-strewn wastelands.
More arrived last month when Amisom troops pushed out of Mogadishu and drove al-Shabaab from Afgoye, a riverside town around 20 miles away in a fertile region of banana plantations and orchards. Some of the estimated 400,000 people living rough by the side of the main road to Afgoye - many having fled earlier fighting in Mogadishu - came back to the camps in the city.
Kleinschmidt says malnutrition and mortality rates in Mogadishu have fallen since last year's peaks, but are still unacceptably high. Rape and sexual violence are all too common in the camps. Mogadishu's most vulnerable are easy prey for freelance militias, whom Kleinschmidt describes as "gatekeepers and mafias".
The city's mayor, Mohamed Ahmed Nur, is also concerned. "I have seen signs that militias want to carve the city into fiefdoms these groups need an iron fist," Nur said. A strong, professional police force is key.
Nur draws a distinction between these armed groups and the warlords, whom he describes as "irrelevant" now. "These people are freelance militias because they are not paid well They are not strong."
As attention turns to rebuilding Mogadishu, Kleinschmidt worries that the thousands of displaced may be left behind. "We are still at a critical emergency level in the centre of Mogadishu," he said. "We are trying to give people access to basic security standards and make sure they don't get left behind by the boom."
As Amisom drives beyond Mogadishu, aid agencies are struggling to extend operations in a region where al-Shabaab still carries out suicide bombings and other deadly attacks. Security is a major problem.
At the Zona K camp in Mogadishu, a crowd of women berated a visiting aid official. "You come and do nothing," the official muttered, quoting the women as he climbed back into the armoured carrier he had arrived in.
Western aid organisations are also struggling to build relationships with new players from Muslim countries. Turkey is taking a lead in Somalia, building roads, clearing rubbish and operating hospitals, and winning international plaudits as it does so.
At the Egyptian-run Zamzam hospital, doctor Ahmed Hassan from Cairo is eager to show visitors how staff treat complex fractures and deformities with the Ilizarov apparatus, a complex mesh of steel rings and wire. The hospital, which is funded by the Arab Medical Union, has a dozen doctors and sees around 1,020 patients a week.
Nur wants to see more long-term foreign investment, not just aid, to deal with what he calls symptoms, like water-borne diseases. "It's a market. The NGOs are doing business and no one wants to phase out their business," he said, admitting that some sectors would need outside help.
"I'm expecting the international community, particularly the UK and US, to invest in electricity, water and roads."
Others say the most vulnerable are not yet able to survive without aid.
The long rains have been below average, and although the UN says famine is unlikely, there is still the risk of food shortages.
"The knock-on effect of poor rains or locust infestations, which we are seeing more of this year, will have an impact on displacement," said Justin Brady, head of the Somalia office for the UN's Office for the Co-ordination of Humanitarian Affairs. As Amisom and its allies continue to pursue al-Shabaab into the south, there will also be more people on the move.
It may be too early to talk about building resilience. "Resilience is an endurance test, and everyone's endurance is lower this year," said Brady. Across Somalia, around 2.5 million people still need aid, with 1.4 million displaced from their farms and homes.
Despite the challenges, Nur is optimistic. "No country is as resilient as Somalia. It existed for 21 years without a government, courts or military, and it is still functioning," he said. "We can rise from the ashes. What we need is visionary leadership to take people out of this mess."
A lot hinges on whether or not the weak, UN-backed transitional federal government, which is due to be replaced by a new administration by 20 August, can deliver credible change.
While some analysts talk cautiously of a "tipping point" in the battle against al-Shabaab, there are fears those involved in the tortuous political process may be less than eager to change the status quo - a war economy that has been lucrative for some in Somalia.