A pirate with a full beard makes an ironic salute as I walk towards him across the red gravel of the prison yard in Garowe, the capital of the Somali region of Puntland. His fellow prisoners turn away in disgust or yell curses at me through the bars.
"We hate you. It's your fault that we are sitting here like animals in a cage. It's humiliating that white men always come and take photos of us and repeat the same stupid questions," scoffs the pirates' spokesman, Abdi Mahad.
There are 47 ex-pirates locked up in Garowe, most of them serving decades-long sentences. According to the prison warden, only the lowest ranking pirates are doing time in the EU-funded facility, along with soldiers from the jihadist insurgent group al-Shabab, petty cattle thieves, and domestic abusers.
This is what the flagship of Western engagement looks like up close: 47 luckless men behind bars on a rocky plateau in a country tested by drought and instability.
But the fight against piracy has produced results. To protect the shipping lanes through the Gulf of Aden, the international powers sent warships and the EU trained the Somali coast guard. At piracy's peak in 2010-13, more than 100 ships were being hijacked per year and millions of dollars paid in ransom. In 2015 and most of 2016 there were no successful hijackings.
The EU's Operation Atalanta is still patrolling the Gulf of Aden alongside the Indian, Russian, and Chinese navies. But NATO's vessels left for other hot spots in December last year, and the pressure on the pirates has decreased considerably.
As a result, the attacks have begun again. At least five ships have been hijacked off the coast of Somalia this year, among them the oil tanker Aris 13 and a fishing vessel, which was transformed into a so-called mother ship from where new hijackings can be orchestrated.
Piracy's money capital
Puntland, a rugged province at the tip of the Horn of Africa, is where piracy began; it's also from here that several of the recent attacks have been launched.
Puntland is an autonomous region, slightly better off than the rest of Somalia, but it still suffers from chronic poverty and insecurity. It is where so-called Islamic State has established a toehold, and is also a base for al-Shabab. Every week there are assassinations, ambushes, and suicide attacks.
Garowe, 200 kilometres from the coast, houses the region's politicians and business elite. Lots of investment in the pirate industry has come from the wealthy in this city. The evidence is in the skyline: the unmistakable Holy Day hotel for example, shaped like the hull of a ship, is owned by a famous pirate who has now transformed it into apartments.
In front of another of the city's hotels waits a 10-metre-long pink limousine. Ali Ahmed rents it out for $50 an hour and says there was a great demand for it during the heyday of piracy. Now it's only in use a couple of times a month, mostly for weddings. One of the front wheels is flat.
Garowe is a surprisingly cosmopolitan city. There are electricians from India, Pakistani construction workers, Kenyan chefs, Ugandan receptionists, tattooed South African security guards, and several Somalis who have returned from distant places like Stockholm, Melbourne, and Minnesota.
People walking in the streets are not armed. Money is still being laundered, but the criminals have become more discreet. The notorious arms dealer Gaagaale � "he who stutters" � no longer has a shed down by the roundabout. You can, however, still buy Makarov pistols from him for $1,600 or a Kalashnikov for $1,400 if you know someone who has his number. Apparently, my Danish-Somali guide does.
The criminal networks
We drive to the Puntland Development Research Center, a respected NGO, to find out how the pirates have made a comeback after seemingly being reduced to a problem of the past.
"Their access to ships was blocked, but the criminal networks prevailed. Therefore, they have resumed the attacks now that the world seems to have forgotten about them again, explains Abdinasir Yusuf, who has been researching piracy and criminal networks in Somalia for 10 years.
Only the increased number of guards on the ships means that the scale of piracy is smaller this time around.
The first pirates were fishermen who attacked ships that exploited the lawlessness of Somalia to trawl the sea for fish and dump toxic waste. But Yusuf believes this romantic depiction has long lost its truth.
"It's not about fish. It's cynical opportunism. Criminals do what they can get away with � not what they can make a moral case for, he notes.
The same organised criminals who run the piracy network have committed a lot of other crimes as well.
He tells me about a Somali awareness campaign, which the head of the research centre, Ali Farah Ali, participated in together with the aldermen, imams, and clan leaders.
"They challenged the local mafia by presenting real arguments against the benefits of being recruited as a pirate. They are the pirate conflict's unsung heroes. Unlike many Western-led awareness campaigns, they were both matter-of-fact and unpretentious," Yusuf says.
The director himself says he showed illiterate young men in the coastal cities videos of how pirate ships were blown up and statistics proving how few pirates actually struck it rich.
These kinds of initiatives have helped stigmatise piracy. There is evidence of this everywhere in Garowe. Some semi-completed palaces are rapidly turning into dilapidated ruins because nobody wanted to buy them from the pirates when they ran out of money.
Most local businessmen now oppose them. One of them is 32-year-old Ahmed Jama Jowle who earned his money selling used cars and office furniture. Three years ago he opened Classic Stadium, an astroturfed arena. "I wanted to give youngsters an alternative to joining up with the pirates," he explains.
It's evening and the floodlights illuminate a Ramadan Cup game. The quality of the football is quite good � Garowe has won the Somali championship. But only a few, if any, of the boys will be able make a living playing soccer; several of them tell you that nine out of 10 of their friends are unemployed.
Piracy may have taken a hit, but according to the think tanks OEF Research, Oceans Beyond Piracy, and Secure Fisheries, new business models are being developed by its entrepreneurial leaders � including people smuggling and arms smuggling.
"Pirates have been smuggling migrants for a long time, one of the main authors of the report, Ben Lawellin, explains in an email. It has helped them stay afloat while the piracy was at a low point, and the practice has helped finance the recent attacks."
On the outskirts of Garowe is a large camp for refugees and internally displaced persons. We call it Washington because the tall solar cell lampposts resemble skyscrapers at night from a distance," laughs 20-year-old cook Idil Ghalbi. She is sitting in front of a small restaurant with walls of milk cartons, together with some women who are also Somalis born in Ethiopia.
They have fled the unrelenting clan wars of the border region and a drought that has left over six million Somalis in need of emergency aid. On her way from the border to Garowe, she was forced to pay (all told) the equivalent of $1,800 to unknown gunmen at the countless roadblocks.
Out of Puntland
Two of Africa's largest migrant routes run through Puntland up to the region's big northern port city of Bosaso. One goes from there by boat to Yemen and on to the Gulf States, the other via Sudan and Libya to Europe.
It's estimated that each migrant on these routes pays smugglers around $10,000. Usually the amount is only due near the end of the journey, but the stories of abuse and extortion en route are legion and shocking.
A spokesperson for the 'Washington' camp estimates that each month about 100 people quietly leave. They rarely talk about their plans, since it's forbidden to migrate, which only increases the opportunities for smugglers to take advantage.
A year ago, Abdikadir Mohamud Barre left Kismayo in southern Somalia with the intention of reaching Europe, since it was only al-Shabab that could offer him a steady job. The 23-year-old was arrested in Ethiopia and sent to the jail in Garowe, where the pirates also serve time.
His journey started when he was asked by someone he was chewing khat (a mildly narcotic leaf heavily used across the region) with whether he wanted to migrate. His answer was yes. Then they called some local smugglers who arranged everything and told him precisely what to do. He never met the smuggler bosses.
"But there were Somalis along the entire smuggler route and many of them looked like hardcore criminals � whether some of them were pirates, I don't know," he says.
We are interrupted by a malnourished cat throwing itself against the plastic window in the prison's living room. "Everyone wants to leave, as you can see. I'll try again as soon as I am released."
The criminal networks are difficult to map because most people with access to first-hand information about their methods work for the intelligence agencies and rarely give interviews. But through a common acquaintance I convince one to make an exception.
He is Somali, does freelance consultancy for foreign intelligence services, and has just completed several months of fieldwork among Puntland's migrant smugglers.
We meet on the roof terrace of my hotel. A minaret calls to evening prayer, and the street below us is full of children playing, and bleating goats. I'm allowed to read an excerpt from his report, in which a number of confirmed migrant smugglers are mentioned by name.
"It was not the focus of the report, but I found out that several pirate moneymen have become rich off of the migrant smuggling," he says.
"One of them is a police officer. He told me that he has earned a great deal of money on migrant smuggling. He claimed not to be active anymore, but several other smugglers said he was. According to the police officer and the other smugglers, the pirate bosses and their networks play a major role in both the smuggling of weapons and human beings."
The consultant explains that there are no clear boundaries between the criminal networks based on the type of crime they commit. "Instead, they are separated from each other based on which regions they operate from, he says.
The same boats often smuggle migrants to Yemen and weapons the other way. Those who are based east of Bosaso are focused on selling weapons to Islamic State � those west of Bosaso typically sell to al-Shabab."
It is easier for the terrorist groups to work together with the smugglers than to do the smuggling themselves. And it makes sense for former pirates to invest in any type of ship-borne smuggling.
"It is a big logistical operation to transport, house, and feed migrants who do not pay in advance. The moneymen behind the pirates and their network of business people from the same clan have this money, the consultant says.
And they needed something to invest in after it became difficult to hijack ships in Puntland around 2012 because of all the foreign warships and guards on the ships.
Friends in high places
Puntland's smuggling gangs collaborate not only with pirates and terrorists, but also with some of the region's politicians. These politicians are dependent on shady arms deals because the UN has had an arms embargo placed on Somalia since 1992.
Each year, a UN monitoring group produces a detailed report on how effectively the embargo is enforced, and the report is always full of exciting details about Somalia's organised criminals. The latest report from October deals with, among others, the pirate boss Isse Mohamoud Yusuf 'Yullux's' relationships with politicians, weapons smugglers, and Islamists.
It was Yullux who kidnapped a Danish yachting family from Kalundborg in 2011. Yullux's orange henna-bearded cousin, Sheikh Abdulqader Mumin, leads IS in Somalia, which is part of the so-called Qandala-Hafun network.
Among the network's well-known political friends in Puntland is a former minister of fisheries and the governor of the Bari region from 2011-15. According to the report, a representative of the network transfers $4,000 per month to an account in the Puntland Treasury Department for each illegal foreign fishing vessel once more bottom trawling off the coast, with former pirates employed as private security guards.
Jonnah Leff, who has researched Somali smuggling networks for Conflict Armament Research since 2013, confirms by email that Puntland's government is most likely still using these smugglers to provide weapons for their soldiers: "It's systemic. It's also why the smugglers are able to continue operating with impunity. They're all related by clan.
One of the most prominent critics of the links between pirates, politicians, smugglers, and extremists is Abdirizak Dirir 'Duaysane'. He founded Puntland's anti-piracy unit in 2010 and until recently he led it with considerable success. From May 2012 to this year, no pirate was paid a ransom fee in Puntland.
According to Duaysane, piracy has returned because Iranian, Yemeni, and Asian trawlers have impunity. They need to be stopped, or even more angry fishermen will join the ranks of the pirates, Duaysane warned in an interview with BBC Somalia in March this year. That same evening, he was fired.
"The government of Puntland is systematically collaborating with pirates and illegal bottom trawlers," Duaysane told me when I met him at the extravagant Laico Regency Hotel in Kenya's capital, Nairobi. They do not fight maritime crime, but are accomplices to it."