Image copyright Met Police Image caption A photograph of Maxwell posing with cannabis, recovered from one of his memory cards

The jailing of Royal Marine Ciarán Maxwell for terror offences raises troubling questions for the military.

How was an Irish republican with links to violent dissidents able to infiltrate an elite Royal Navy unit and evade detection for so long?

For five years, Maxwell researched, acquired and stockpiled an arsenal of weapons, including material stolen from his base.

A former Army officer has called for an overhaul of the vetting system.

On the face of it, when the man from Larne, a coastal town in County Antrim, began the gruelling 32-week training to become a Royal Marine in 2010 he could not have seemed prouder.

Image copyright An Phoblacht Image caption A young Ciarán Maxwell was beaten by loyalists before he became a marine

He posted on his Facebook page: "Pain is temporary, the Green Beret is forever."

Dangerous double-life

But he had gone into the military nursing a grudge after being severely beaten by a loyalist mob oozing sectarian hatred and wielding golf clubs eight years earlier.

They left the teenage, Catholic boy with a fractured skull.

Image copyright Met Police Image caption An underground hide found in Capanagh forest, County Antrim, Northern Ireland

His case featured in the republican newspaper, An Phoblacht, and is said to have left Maxwell "angry and traumatised".

So even before he completed his Marines training, Maxwell was living a dangerous double life.

He had dedicated himself to creating an arms cache for use against the British state he was purportedly serving.

'No vetting failure'

It is not clear whether Maxwell was asked about the incident in which he was beaten as part of his security vetting to become a Royal Marine.

He will have undertaken a long interview, which usually covers most areas of the applicant's life, including his family background.

Image copyright Metropolitan Police Image caption A balaclava recovered from a hide at Powderham New Plantation

The Royal Navy rejects the suggestion there was a failure of vetting in the Maxwell case, but would not talk about specifics.

"All security personnel are subject to security checking prior to employment and at regular intervals throughout their careers," said a spokesman.

But Doug Beattie, who served three tours of duty in Afghanistan as a captain in the Royal Irish Regiment and is now an Ulster Unionist politician, told the BBC: "We could have been looking at loss of life perpetrated at the hands of a serving soldier of the British military.

"If we don't have a look at our security checks and how we vet people before they join the military, we're going to have problems in the future."

Image copyright Met Police Image caption Timers recovered from a forest in County Antrim, Northern Ireland

'Very alarming case'

The rogue marine stole rounds of military ammunition and detonators from his unit, exploiting weaknesses in a system that is mainly based on trust.

At the end of training exercises, military personnel have to declare any ammunition they have not used and they may be searched but it is nearly impossible to account for every round.

Maxwell was careful to smuggle out small amounts at a time and he carried them back to Northern Ireland on ferries where there are fewer security checks.

But he took enormous risks, including storing drugs such as LSD in his work locker.

Image copyright Met Image caption Maxwell's hide at Carnfunnock Country Park near Larne, County Antrim

Commander Dean Haydon, the head of counter terrorism command at the Metropolitan Police, described the Maxwell case as "very alarming".

"The fact that ammunition was taken from a military base is clearly of concern and we are working with the military in that regard."

The security of weapons, ammunition and equipment is taken "very seriously", according to the Royal Navy.

"All personnel are instructed in appropriate procedures and any incidents are investigated and action taken where necessary," added a spokesman.

During Maxwell's sentencing hearing, it emerged that he advised the military after his arrest on how it could tighten up the procedure for checking ammunition out of the stores.

'Attempt to kill'

Image copyright Met Police Image caption A greenhouse used by Maxwell at Powderham New Plantation in England

Even more alarming than his theft of ammunition is that some of Maxwell's improvised pipe bombs are unaccounted for.

"We assess that it's a possibility that a small number - and I would stress that it's a small number - of devices that Maxwell would have made were not recovered and are in the hands of violent dissident republican groupings," said Assistant Chief Constable Stephen Martin of the Police Service of Northern Ireland.

"These groupings do carry out attacks in Northern Ireland - they do attempt to kill people and if they have devices they will use them.

"But I want to reassure people that we are doing everything that we can as a police service to try to constrain these groups."

Image copyright Met Police Image caption A handwritten note from Maxwell, recovered from hides at Powderham New Plantation

The group that Maxwell was supplying pipe bombs to calls itself the Continuity IRA (CIRA), which believes it is carrying on the original IRA mission to force the British out of Northern Ireland.

Maxwell admitted he was working with CIRA member Niall Lehd, who went to the same school as him and who was convicted of possessing explosives with intent to endanger life in 2014.

Maxwell supplied the explosives.

Dark Troubles shadow

Soon after his release from a short prison term two years later and while still on licence, Lehd teamed up again with Maxwell.

The pair concealed explosives in various hides around Larne.

Image copyright Met Police Image caption A police vest recovered from a hide in Capanagh Forest, Northern Ireland

It is unclear why the diligent and highly-organised marine threw in his lot with a man described by his trial judge as "more a risk to yourself than others".

And the police are reluctant to talk about the relationship between the men or say why Lehd was not charged as part of this investigation.

Though his eventual arrest in August 2016 brought Maxwell's long years as an undercover terrorist to a dramatic end, this case is another reminder of the dark shadow that Northern Ireland's Troubles have cast over the region and beyond.