Algerian President Abdelaziz Bouteflika last month dissolved the Department of Intelligence and Security (DRS), the powerful state security service long seen as the nexus of political power in the country - a move that has raised questions about the extent of power wielded by the country's intelligence apparatus.
The dissolution of the DRS followed the removal of its long-standing chief, Mohamed Mediene, last September.
Mediene, more commonly known as Toufik, had been head of the organisation for 25 years and was believed by many to be the real power behind the president.
Senior figures in the DRS and the army were instrumental in propelling Bouteflika to the presidency in 1999. DRS support was also crucial to Bouteflika's successful re-election campaigns in 2004, 2009 and 2014.
Now, the DRS will be replaced by the Department of Surveillance and Security (DSS) which, unlike its predecessor, will report directly to the presidency.
Any reduction in the influence of the state security service would be a major shift in Algerian politics. But opinion is divided over whether the DRS' dissolution signals an end to the power wielded by senior officials in the organisation.
Some say they have been definitively marginalised. "Over the past five or six years, the presidency and the DRS turned on each other, but Bouteflika has won a decisive victory," said Michael Willis, an expert on Algerian politics at Oxford University. "It shows Toufik wasn't the all-powerful figure he was believed to be. He was vulnerable."
Others believe that Mediene has retained influence despite his sacking in September. "A lot of people are saying this," said one Algerian businessman close to political insiders in Algiers. "It's just a reorganisation. Mediene is still strong. A lot of people believe that he is still acting behind the scenes."
Despite the recent changes, there are some lines of continuity in the state security apparatus. The man appointed to head the new security service, Athmane Tartag, also headed the DRS after Mediene's departure. Tartag, also known as Bachir, had earlier served as the organisation's second-in-command and as head of internal security.
But there is evidence to suggest that the presidency has been eroding DRS power for some time. Although Bouteflika relied on powerful individuals within the military elite during his first three presidential terms, he also actively sought to strengthen the presidency at the expense of the security services.
"I think the DRS was already in decline prior to last month's decision," said Geoff Porter, president of North Africa Risk Consulting, a firm that specialises in political and security risk and business intelligence. "In some ways, I think it benefited from the myth of omnipotence rather than its actual capabilities."
Bouteflika announced early in his presidency that he wished to rule with the full powers of the institution, and during his first term he pushed several ageing generals into retirement.
The president and the DRS have clashed in the past, notably in 2010 when the DRS launched corruption investigations into state hydrocarbons company Sonatrach, the largest company in Algeria, on allegations of corruption in the awarding of contracts.
DRS' lead role in the investigations gave the impression that the government was under attack by its own security service. Many of those under scrutiny were appointees of then Energy Minister Chakib Khelil, a close associate of Bouteflika, although Khelil himself was not charged.
Whether or not Bouteflika remains personally able to compete with the DRS for political influence is questionable; the president has been in ill health for many years.
He was hospitalised in Paris in late 2005 for what was officially a stomach ulcer but was rumoured to be cancer, and in 2013 he suffered a severe stroke that has left him partly paralysed, confined to a wheelchair and able to make only very occasional public appearances.
Presidential decision-making is now widely believed to have been assumed by Bouteflika's entourage, known as the clan Bouteflika, and in particular his brother, Said Bouteflika. "We're not really sure that Bouteflika is still making the decisions due to the state of his health," explained Willis.
Since 2013, when the president's illness provoked calls from opposition politicians for his removal, Bouteflika loyalists have accelerated their accumulation of power around the presidency.
"They have taken over the key levers of state, so that they can ensure in the event of a transition they are not targeted," said Willis.
"The Bouteflika clan is coup-proofing," said another Algeria analyst based in the United States, who spoke on condition of anonymity. "They are paving the way for the succession."
In August 2014, Bouteflika issued a series of decrees removing several civilian and military advisers from government positions. These included the president's defence adviser, Mohammed Touati - known as "the brain" - who formally retired from the army in 2005, but took on a political role at the presidency in 2011.
Touati has been described as a Trojan horse for the military establishment in the government, and his removal was seen as a sign that the presidency was pushing back against the influence of the military elite.
In July 2015, the heads of three groups responsible for providing security for Bouteflika were dismissed within 48 hours, after a lapse in security at the presidential residence at Zeralda, about 30km west of Algiers. The heads of internal security, presidential security, and the Republican Guard were all removed in what was seen as a move to ensure the loyalty of those close to the president.
In another sign of the government's apparent authority over the security services, in late August the former head of counter-terrorism, Abelkader Ait-Ouarab, also known as Hassan, was arrested. He was later sentenced to five years' incarceration on charges of destroying documents and disobeying military orders.
The appointment of Tartag to lead the DRS, and now the DSS, might be seen as a sign that the old military elite has retained its influence. But it is unlikely that Tartag will be able to wield the same power as Mediene, say analysts.
Bouteflika dismissed Tartag from the DRS during his first presidential term, recalled him in December 2011, and sacked him again in July 2014, perhaps in part owing to the deadly attack on the In Amenas gas facility the previous year.
By the time Tartag was recalled yet again to head the DRS in September 2015, he had served as counsellor to Bouteflika for a year at the presidential headquarters, El Mouradia.
"Tartag has been institutionalised," said the US-based analyst. "He's seen as a protégé of Mediene, but he's in the presidential camp."
Willis agreed. "After Tartag was removed as the DRS second-in-command, there was a feeling that he came back as much closer to the presidency than he had been. He's not seen as a political rival or a successor to Mediene."
The opacity of the Algerian state means that the confusion over who wields power, and how much, is likely to remain unresolved. But whoever is in power faces challenges greater than at any point since Algeria's civil war in the 1990s.
The threat of armed groups across the region, the collapse of oil prices and the spiralling cost of living for impoverished Algerians are all putting pressure on the country's authoritarian political system.
"Bouteflika's entourage has won a power struggle," Willis said. "The key question is what they're going to do with it."