Image copyright West Midlands Police

London Bridge attacker Usman Khan came to the attention of counter-terrorism investigators because he was involved in a highly active cell around Stoke-on-Trent, part of a wider network of radicals then headed by the preacher Anjem Choudary.

MI5 and the West Midlands Counter Terrorism Unit had intelligence that a group of nine men from London, Cardiff and Stoke, including Khan, wanted to bomb the London Stock Exchange. The plot was supremely incompetent and amateur.

Khan also wanted to set up a terrorism training "madrassah", or school, in Kashmir to train a new generation of British militants to either fight out there or bring their skills home.

Khan and the others were convicted and jailed in 2012 - and the ultimate dilemma for the authorities was whether the men were simply fantasists who, hopefully, would grow up.

The West Midlands Counter Terrorism Unit and MI5 team who worked on the investigation had no doubt the men were dangerous - even if they did not have capability.

And while Mr Justice Wilkie, the judge presiding over the case, received a letter from Khan saying he had recanted, he had his own doubts - not least because of the nature of the conversations that had been caught during surveillance.

The judge gave Khan a special prison term known as Imprisonment for Public Protection (IPP).

That meant he would serve at least eight years and could not be released unless he had convinced the Parole Board he was no longer a threat.

Some of the other members of the cell received a sentence which dealt with their dangerousness differently.

They would serve the second half of it in the community on a licence to monitor their behaviour. And following that, additional years of monitoring.

When Khan appealed against his sentence, senior judges agreed he should have been treated the same way as his co-defendants.

Image copyright West Midlands Police Image caption Usman Khan, circled, with his fellow defendants in a surveillance image released by police in 2012

His IPP was replaced by the same extended sentence (reflecting dangerousness) given to some of the others, meaning he would definitely still spend eight years in jail before release and monitoring.

If he broke the licence he could be immediately sent back to prison.

Khan had also been asking to join a deradicalisation programme - including sending a letter in October 2012 asking for the Home Office to provide someone to work with him.

His solicitor, Vajahat Sharif, has told the BBC that Khan repeatedly asked him for help in finding someone.

Mr Sharif said he wanted a very specific jihadist ideology expert to work with his client because he feared Khan's hate was so deeply-rooted.

Media playback is unsupported on your device Media caption London Bridge attacker "wanted to deradicalise" at time of conviction - lawyer

So while he may have received some help, his lawyer, for one, thinks it was not enough.

When Khan was released on licence, he was subject to a variety of forms of management in the community, as is largely standard for terrorism offenders:

Khan was wearing a GPS tag to monitor his specific movements

He was sent to a bail hostel in Staffordshire where his comings and goings could be supervised

It's likely - but unconfirmed - that he was banned from speaking to his former associates

And he was obliged to take part in the government's "Desistance and Disengagement Programme" (DDP)

DDP is now a key part of the counter-terrorism strategy and involves tailored counselling and psychological intervention in the lives of terrorism convicts leaving jail.

More than 100 individuals went through the course between the beginning of its trial in October 2016 and September 2018. There is now funding in place to accommodate up to 230 individuals a year.

The scheme aims to address many of the triggers that lead someone to turn against society - from a personal identity crisis and chronic self-esteem problems, through to personal grievances and immersion in extremist ideology.

One of Khan's associates, jailed alongside him in 2012, was Mohibur Rahman.

He attended a deradicalisation course while in jail - but he also met other extremists inside.

He was subsequently released and then jailed for life for his part in an embryonic plan to carry out a vehicle and knife attack in Birmingham.

Image copyright West Midlands Police Image caption Mohibur Rahman (left) alongside fellow defendant Tahir Aziz

The end of that plot was a major win for the police and MI5 - but it also involved two other former terrorism prisoners who had not changed their ways.

Each regional counter-terrorism unit is also supposed to take an interest in the activity of released individuals on their patch.

Khan would have required police permission to travel to London before his attack so as to not trigger an alert. On Saturday, Scotland Yard said Khan was, to the best of their knowledge, complying with all his release conditions.

MI5 may have been monitoring Khan too, as it has a role in looking at prisoners leaving jail - although they are typically considered a low risk because it takes time for them to re-engage.

And so the biggest problem is knowing for sure that someone has reformed - even if they have been on a deradicalisation programme.