Sleeper cells, prisons teeming with extremists, camps crammed with their wives and children -- perils abound in Syria, two months after the "Islamic State" (IS) was declared defeated.
The US-led international coalition pronounced the death of the so-called "caliphate" of IS on March 23, after a nearly five-year battle against the militant group.
The elimination of the physical territory closed a long chapter in the conflict, but the Syrian Democratic Forces (SDF) and the military coalition backing it have warned the fight is far from over.
IS is still able "to carry out regular attacks on a weekly basis", said Tore Hamming, a scholar of extremist movements at the European University Institute in Florence, Italy.
Even after losing their last scrap of territory in the village of Baghouz, the extremists retain a presence in Syria's vast desert and hideouts elsewhere in the country.
They also are apparently eyeing Afghanistan, Pakistan and India as places where they can regroup.
A recent United Nations report said IS in Afghanistan has between 2,500 and 4,000 members.
In May, IS announced the creation of "Pakistan Province" and claimed that its "Hind Province" branch attacked Indian forces in the Indian-ruled portion of Kashmir.
Nicholas Heras, an analyst at the Centre for a New American Security, warned that IS still holds sizeable sway over "networks of local support".
"A big part of the IS strategy to regrow is that it continues to have strong ties into some of the local tribes in eastern Syria and western Iraq," he said.
As both regime and US-backed forces seek to hunt down IS sleeper cells on the run, the Kurdish authorities in north-east Syria face another major challenge.
Thousands of alleged extremist fighters -- including hundreds of foreigners -- are now being held in Kurdish-run jails, while their relatives languish in overcrowded camps for the displaced.
Their numbers have created a major headache for the semi-autonomous Kurdish administration, which now wants to put suspected extremists on trial.
Since 2014, IS fighters have been accused of carrying out beheadings, mass executions, rapes, abductions and ethnic cleansing.
They stand accused of stoning to death women suspected of adultery and of forcing homosexuals off the top of high buildings.
While many extremists are now detained, they still pose a threat, according to analysts.
"These detention centres are becoming breeding grounds for radicalisation," the Soufan Centre said in a report published on April 12.
"There is also a major risk of IS-engineered prison break attempts," said the organisation, which specialises in security analysis.
Hamming said, "Neither Syria nor Iraq have the resources or the political stability to properly handle such a large number of prisoners".
Kurdish authorities are calling on the international community to help set up and guard new high-security detention facilities, after many Western states refused to take back their nationals.
However, a number of countries have recently repatriated hundreds of citizens.
Kurdish authorities in northeast Syria Wednesday (May 29) handed over 148 Uzbek women and children linked to IS to Uzbek diplomats for repatriation, with more than 300 Uzbeks were scheduled to be sent home, officials said.
Kazakhstan on May 10 evacuated 231 of its citizens, most of them children, from Syria after they travelled or were taken there to join IS.
The evacuation follows a similar operation in January that saw 47 Kazakhs returned to the country, some of whom were subsequently arrested for extremism-related crimes.
Syria's Kurds are also calling for much more support for displacement camps, where tens of thousands of people have amassed after fleeing battles against IS.
The camps host 12,000 foreigners -- 4,000 women and 8,000 children -- who are kept under surveillance.
The largest of these camps, Al-Hol, has seen its population swell to more than 73,000 people, with conditions deteriorating as a result of the mass influx.
The International Rescue Committee has reported severe acute malnutrition, pneumonia and dehydration among children in the camp.
The United Nations says 211 children under the age of five have died on their way to Al-Hol or shortly after arrival since December.
The Soufan Centre warned the humanitarian crisis could be used as a recruitment tool.
IS "fighters are seeking ways to capitalise on the suffering in these camps to rejuvenate their organisation", it said.
As for the offspring of alleged foreign fighters, said top Syrian Kurdish foreign affairs official Abdel Karim Omar, "if these children are not sent home, re-educated and re-integrated into society, they will become future terrorists".