Brazil prison riots: What's the cause?
A spate of violence in Brazil's prisons has cast a spotlight on a system which appears to be near a state of collapse.
Almost 100 inmates lost their lives in the first week of January alone - brutally murdered, the guards apparently unable to stop the bloodshed.
But how has it come to this?
Problem one: Overcrowding
A crackdown on violent and drug-related offences in recent years has seen Brazil's prison population soar since the turn of the century.
Number of inmates in 2014
232,755 Inmates in 2000
1,424 Detention centres
157% Average occupancy rate
The prison in Roraima state where 33 inmates were killed on 6 January held 1,400 inmates when a deadly riot started. That is double its capacity.
Overcrowding makes it hard for prison authorities to keep rival factions separate. It also raises tensions inside the cells, with inmates competing for limited resources such as mattresses and food.
In the relatively wealthy state of Sao Paulo, a single guard oversees 300 to 400 prisoners in some prisons, Camila Dias, a sociologist at the Federal University of ABC in Sao Paulo and expert on Brazil's prison system, told Reuters.
That means it is relatively easy for prisoners - and gangs - to take control of the facilities. As a result, "when the prisoners want to have an uprising, they have an uprising," Ms Dias said.
- Drugs gang 'kills 33 inmates' in Brazilian jail
- Brazil sets out security overhaul after deadly riot
- Brazil prison riot kills at least 56
Problem two: Gang warfare
Killings are already common within the walls of Brazil's prisons - 372 inmates lost their lives in this way in 2016, according to Folha de Sao Paulo newspaper - but this recent surge has been linked to the breakdown in a two-decade truce of sorts between the country's two most powerful gangs.
Up until recently, the Sao Paulo-based First Capital Command (PCC) drug gang and Rio de Janeiro's Red Command had a working relationship, supposedly to ensure the flow of marijuana, cocaine and guns over Brazil's porous borders and into its cities.
But recently they have fallen out - although the exact reasons why remain unclear.
And following the government crackdown on criminal gangs, there are thousands of members of both gangs locked up inside Brazilian prisons.
Rafael Alcadipani, a public security expert at the Getulio Vargas Foundation think tank in Sao Paulo, told Reuters it means any feud between the two sides on the streets will almost certainly spill over into the largely "self-regulated" jails.
"We see that as soon as we have a gang war, these killings are inevitably going to happen because the state has no control over the prisons," he said.
Problem three: Lack of resources
Many Brazilian prisons are underfunded.
Following the deadly riots in Amazonas, state governor Jose Melo asked the federal government for equipment such as scanners, electronic tags and devices which block mobile phone signals inside prisons.
His request illustrates the lack of basic equipment in prisons which house large numbers of prisoners.
He also said that the state police force was struggling to cope and requested that federal forces be sent.
Poorly-trained and badly-paid prison guards often face inmates who not only outnumber them but who also feel they have little to lose as they face long sentences already.
Following the 1 January riot, which left 56 inmates dead in a prison in Manaus, the Brazilian government announced a plan to modernise the prison system.
But with Brazil going through its worst recession in two decades and a 20-year cap on public spending in place, it is hard to see how the government plans to fund it.