As the war in Ukraine enters its fifth month, President Volodymyr Zelenskyy appears to now be engaged in another battle: purging powerful security agencies of collaborators and Russian agents.
In an address on Monday, the Ukraine President confirmed a total of 651 collaboration and treason cases have been opened against law enforcement officials.
"Such an array of crimes against the foundations of the national security of the state — and the connections detected between the employees of the security forces of Ukraine and the special services of Russia — pose very serious questions to the relevant leadership," Mr Zelenskyy said.
"Each of these questions will receive a proper answer."
For months, security service personnel have been removed against a backdrop of the brutal, ongoing invasion of Ukraine.
At one end of the spectrum are people who are accused of failing to do their jobs properly in weeding out traitors and potential collaborators with Ukraine's enemy.
In May, Roman Dudin was dismissed from his post as head of the State Security Service of Ukraine (SBU), Kharkiv region, for "not working to protect the city during the initial days of the full-scale war and thinking only about himself".
The Kyiv Post cites well-known Kharkiv volunteer Roman Donik as saying that Mr Dudin fled the city on February 24 and evacuated all his people 250 kilometres from Kharkiv.
However, these allegations do not appear to be the only issue plaguing Ukraine's security service. At the other end of the spectrum is a more insidious problem: officials and locals who stand accused of being traitors and collaborators.
The assistant to the head of the Kherson SBU and head of the Anti-terrorist Centre was reportedly detained in April on suspicion of treason for allegedly sharing information about the evacuation operations to Russian intelligence.
And, more recently, Oleh Kulinich — who was in charge of the SBU's department for the occupied Crimea — was dramatically arrested on Saturday on suspicion of treason in what Mr Zelenskyy dubbed a process of "self-purification".
For years, Ukraine has been on alert to threats from spies infiltrating its systems of power, but in the midst of war and amid a reshuffle of Mr Zelenskyy's own inner circle, the issue has come into sharp focus.
Kyiv is facing its biggest internal purge of the war
Since coming to power, Volodymyr Zelenskyy has surrounded himself with a commanding team of loyalists, some linked back to his days as a television star and others plucked directly from his campaign.
His chief of staff, Andriy Yermak, was a former movie producer and lawyer who is now considered the second-most influential politician in Ukraine.
Serhiy Shefirm was appointed aide to the president after working with Mr Zelenskyy in television and Kirill Tymoshenko is now overseeing humanitarian aid after working as a videographer.
While the team's loyalty has proved priceless during Russia's invasion, rumours have swirled for more than a month that the Ukrainian leader wanted to replace his longtime friend and spy chief, Ivan Bakanov, with someone more suitable.
Mr Bakanov was appointed to his position as head of the SBU shortly after Mr Zelenskyy got the top job, having played an instrumental role in his friend's insurgent campaign for the presidency.
Opposition figures were critical of the appointment, the BBC reports, arguing that the former TV producer was unqualified to lead the sprawling agency.
However, Mr Zelenskyy would not be deterred from his captain's pick, surrounding himself with trusted allies as he sought to assert himself in an environment of widespread distrust of the country's bureaucracy.
"It's absolutely understandable that he brought in his friends, his trusted allies, but they should also then prove themselves as efficient managers," Ukraine political analyst Mattia Nelles told the ABC.
The new President hoped Mr Bakanov would clean up the SBU and prove to Western institutions that Ukraine was open to reform.
However, by June, Mr Bakanov and Mr Zelenskyy were reportedly rarely speaking. A Ukrainian official speaking on the condition of anonymity told Politico they were not satisfied with the SBU chief's managerial skills and were "working to get rid of him".
Then, this week — after the high-profile arrest of Mr Kulinich — Mr Zelenskyy sidelined Mr Bakanov as well as top state prosecutor Iryna Venediktova, citing dozens of cases of collaboration by members of their agencies in Ukraine.
Mr Bakanov was officially ousted by parliament two days later in what was the biggest internal purge of the war.
The deputy SBU director and regional chiefs in several other cities were also dismissed.
"I would say that the track record of Bakanov is, at best, mixed based on what we know," Mr Nelles said.
"He was trusted by the President, but he was leading a gigantic [agency] of 30,000 men, which is nearly the size of the FBI."
The former spy chief is not accused of betraying his country, but rather of running an organisation where others did.
The secret service likened to 'Swiss cheese'
The SBU is a direct descendant of the Soviet-era KGB and was, at one time, described as the "most powerful institution in the country".
It's also a behemoth, considered to be seven times the size of the UK's M15 and tasked with not only traditional domestic intelligence and counterintelligence-gathering, but also combating economic crimes and corruption.
Like other intelligence services, the SBU largely operates in the shadows, making it difficult to assess its efficacy. However, over the years, it has faced criticism.
There have been allegations of corruption, secret jails, torture and, in 2018, the organisation stirred controversy when it faked the death of a dissident Russian journalist.
The news that Arkady Babchenko had been shot three times and died on his way to the hospital prompted an outpouring of mourning on social media, which later gave way to shock when the SBU announced the journalist was actually alive.
His death was staged, supposedly as a way of catching Russian operatives plotting the journalist's assassination.
"It is pathetic and regrettable that the Ukrainian police have played with the truth, whatever their motive," the head of Reporters Without Borders, Christophe Deloire, told AFP news agency at the time.
Mr Zelenskyy vowed there would be change once he was at the helm, but a reform bill introduced in 2020 to better define the SBU's remit and scale down its workforce stalled once the invasion began, observers say.
The SBU has a long history with Russia's FSB trying to infiltrate its ranks, although this is not unique to Ukraine's intelligence services.
Collaborators and agents were an acute problem back when Russia annexed Crimea, but Mr Nelles said there had been efforts to improve the agency over the years and it was a "positive sign" that so few high-profile figures had been found recently.
Even so, Kyiv appears to be getting serious about cracking down on the secret service after more than 60 people from Mr Bakanov and Ms Venediktova's agencies were revealed to now be working against Ukraine.
"There will be many 'cleanses' because, over the years, many residents of the Russian special services have secretly entrenched themselves within the walls of the SBU, unfortunately," the leader of the Servant of the People party, David Arakhamia, said.
"They got access to materials that they didn't have before."
Observers say the Ukrainian political leadership will have to quickly draw the right conclusions from the failures of the SBU if it hopes to avoid future problems.
With the list of high-ranking SBU officials facing allegations growing, questions loom over decisions made in the early days of the war, including in the strategic city of Kherson.
Enduring questions over the capture of Kherson
Seven days after the invasion of Ukraine, Russian troops seized the Antonovskiy bridge and rolled into the city of Kherson in a lightning-fast advance.
Kherson, a gateway to Crimea, gave the enemy a crucial foothold into the southern region of Ukraine and was the first major city captured by Russian forces.
One of the enduring questions ever since has been why it fell so quickly in contrast with the strong Ukrainian resistance displayed in other areas, which forced Moscow to abandon its push for the capital.
"Kherson was supposed to be the most heavily mined Oblast in Ukraine," Mr Nelles said.
"But the big, unresolved questions remain as to why the Russians [were] able to capture Kherson and pass the bridge, one of only two bridges in the region, across [the] Dnipro [River]."
Only a full investigation will determine what happened in Kherson. Ukraine's defence ministry said in a statement in April that the bridge was mined, but it "faced enemy forces that outmanned us 15 times".
Some Ukrainian officials have told Politico that Russian troops were able to take Kherson so easily because of the failure on the part of SBU officials there to blow up the Antonovskiy Bridge, allowing Russian troops into the city.
With the bridge destroyed, the Ukrainians had hoped to thwart Russia's advance, by making the area a logistical nightmare and halting its takeover by days or weeks.
"It was obvious there was treason in Kherson region," constitutional and policy expert Bohdan Bondarenko told Reuters.
"That there were agents is obvious, now there will be tough counter-intelligence action and outing of these agents. That's why the SBU question is so important. Because it is the SBU that should handle counter-intelligence … and it turned out there were also Russian agents in the SBU."
Yet searching for evidence in a war zone will be a tricky exercise, according to Sara Meger, an international relations expert at the school of social and political sciences at the University of Melbourne.
The task of cracking down on traitors and collaborators is an extensive one, with SBU officials also at work on the frontline of the war and across the country.
While there is very little sympathy for Russia, more than 800 people suspected of engaging in sabotage and reconnaissance for the Russians have been detained since the war began, Yevhinnii Yenin — First Deputy Minister of Internal Affairs of Ukraine — revealed last month.
Those who were caught were either Russian citizens brought in before the invasion began or were driven by financial incentives or political sympathies, according to officials.
Ukraine's enemy appears to have experience similar problems throughout the war, with Vladimir Putin enacting a "Stalinist" purge inside one of Russia's most powerful agencies in April and rumours of Russians hunting down spies in occupied villages.
Yet, the Kremlin has continued its ruthless campaign, despite sustaining very significant material and troop losses.
"They're very committed to the war effort," Ms Meger said.
"And, with both sides sort of equally committed to winning, I think we're just going to see this sort of stalemate persist, and that's going to leave Zelenskyy in a very tough position of trying to maintain morale or sell to his public a rare, very sudden shift in tactic."