A planned military offensive to reclaim Mosul from so-called Islamic State (IS) could see up to a million Iraqis flee their homes. The UN's refugee agency has told the BBC how it and its partners are gearing up to deal with the expected humanitarian crisis by building camps to house those in need.
The much-delayed operation to drive IS from Iraq's second-largest city is expected to begin this month, more than two years after the jihadists over-ran Mosul and proclaimed its caliphate.
In preparation, the UN refugee agency (UNHCR) and its partners are stepping up contingency plans, informed by a number of lessons learned from previous offensives, such as Falluja, says Bruno Geddo, the UNHCR Iraq Representative.
For example, the Iraqi army has been encouraging the residents of Mosul to stay in their homes when possible instead of taking to the open roads, where they could be vulnerable to attack.
"Isis [IS] know where the routes out of the city are and they will kill people escaping," Mr Geddo says.
"There is only a narrow route which is safe to travel through. If too many people try to use them there will be bottlenecks, which are always dangerous. They are easy to attack."
Mr Geddo hopes the Iraqi army will be successful in keeping people in their homes, but says such a plan will be difficult to enforce. For this reason, the UNHCR and its partners are preparing for the worst.
"If [the situation in the city] is arranged in a proper way - everything will be controlled by the Iraqi army - people will not be allowed to flee Mosul," he says.
"If the outflow is uncontrolled there will be chaos and desperation."
'A million people displaced'
An estimated 3.3 million people - equivalent to almost 10% of the population of Iraq - have been uprooted by fighting since the start of 2014. Those currently fleeing Mosul and its surrounding areas join about half-a-million people who fled the city in June 2014.
There are no firm figures on how many people remain in Mosul, but there were more than two million when IS took the city more than two years ago.
Mr Geddo estimates the population could now be "anywhere between 1.2 and 1.5m people".
As a result, the UN believes up to one million people could be displaced by the forthcoming military action, and some 700,000 of those, they believe, will need shelter.
It warns it could be one of the largest man-made displacement crises of recent times.
With current funding levels, the UNHCR says it is able to provide accommodation for 20,000 families - or 120,000 people.
Other groups working alongside the agency estimate they can help a further 50,000 families.
"We will have five new permanent camps up by the end of October and hope to provide 20 more emergency camps closer to the theatre of conflict," says Mr Geddo.
Due to protection concerns, the locations of these emergency camps cannot currently be revealed.
- An "emergency shelter kit" is given to families when tents are not available in camps
- Each pack costs between $79 and $87 (£65-£70)
- The UN currently has 50,000 such kits, with 5,000 arriving in Iraq each week from 18 October. Some 30,000 more will be provided by UN partners from November.
The emergency camps will need to be closer to the city to look after civilians as soon as they escape and will therefore suffer from "a substantial risk" of "mortar or shell attacks", Mr Geddo warns.
So far, he says, the UN has identified locations for four of the emergency camps, but explains the challenge is finding safe places with the right terrain for shelter as well as a water supply.
In the past, there have also been issues with private landowners unwilling to lease land to the UN.
In order to try and create more space for fleeing families, the UN will attempt to move residents out of camps quickly to more permanent accommodation.
One option is a "sponsorship arrangement", Mr Geddo explains, where civilians are sponsored by a family member, a business or a charity.
If they are able to prove that they will be looked after at their destination, the UN will then assist them in making the journey.
Another problem facing the UNHCR, he says, is that a number of civilians may try to escape the fighting by travelling to Syria, where the UN is working with groups to try to ensure people's safety.
"This is more difficult of course, but it could ease some pressure on our camps in Iraq."
The process of securing funding for the relief effort has been a challenge, but has improved since previous crises, Mr Geddo explains.
Previously, large donations only started to come in once action appeared on television screens on the news.
"There is never enough money for any humanitarian situation, but we are more prepared this time," Mr Geddo says.
Vetting for IS
Another lesson learned, he says, is regarding the vetting of those entering the camps.
Accusations that Shia militiamen had previously carried out abuse during security checks means the process will now be carried out solely by the Iraqi army.
"[The vetting process] is absolutely key. This will be the first interaction many people have had after two years under IS control. It must be completely clear that we are helping and that the procedure is a normal one.
"No men will be allowed access to UN camps unless they have been fully security screened," Mr Geddo says. "The process could take several days."
Mr Geddo also suggested there were possible signs that IS in Mosul was running out of funds.
Those fleeing have described how the fighters are now accepting cash payments to allow people to escape the city.
"Previously, the only way to get out was with a smuggler," explains Mr Geddo. "The person would pay $2,000, but it was very dangerous. Both the smuggler and the family would be killed if they were caught trying to escape.
"But recently, we have heard stories - this is not confirmed information - that Isis are accepting a higher payment of $10,000 and will allow people to leave."
However, Mr Geddo adds, IS may want many of the city's residents to stay put until the battle begins in order to use them for their own tactical benefit.
"When [the civilians] flee, they will try to slow down the coalition forces by using civilians as human shields."
This would be yet another aspect to the crisis that the UN and its partners would have to be prepared for.