A man caught with so many indecent images of children that investigators 'gave up counting' has been spared jail time.
Pinky Caine, aged 31, had almost 4,000 illegal photos on his devices and 22,0000 more which were never classified.
He had a secret mobile phone and 'boasted' of hiding his internet history so police would not catch him, Plymouth Crown Court heard.
Caine was also in breach of a suspended sentence for identical offences.
But he avoided immediate custody after a judge heard that it was more than two years since he had last offended and the steps he had taken to tackle his perversion.
His family sacrificed their savings to pay privately for treatment at The Priory, a London psychiatric hospital famous for its celebrity clients.
Handing him a fresh suspended sentence, Judge William Mousley told Caine: “You have been given a huge chance on this occasion. You have come as close as it is possible to get to going straight to prison.
“I am prepared to accept that you do not constitute an immediate risk of harm to the public. There are still hopes of your rehabilitation through work which is ongoing.”
The judge said that there were 22,000 images on his devices which were “questionable”, but as they were not classified they cannot be seen as indecent in law.Caine, of St Johns Terrace in Totnes, pleaded guilty to four counts of possession of indecent images of children in 2018.
The vast majority of the 3,902 files found on his devices were in the lowest bracket, but 12 were in Category A - including videos and images depicting adults abusing children.
He also admitted breaching his Sexual Harm Prevention Order by having an internet enabled mobile phone which was not declared to the police.
Ian Graham, for the Crown Prosecution Service, said that he was handed that order after he was convicted of making indecent images of children in July 2017.
He was given a 12-month prison sentence suspended for two years.
Mr Graham said that police found indecent images on his devices in both May and December 2018.
The barrister added Caine was heard saying that he was "still viewing" indecent images during a group counselling session in August 2018.
Mr Graham said: “He said that he was covering his tracks and he was not worried at that stage about the police finding anything wrong.”
Lee Bremridge, Caine's defence, said that he had pleaded guilty at an early stage and showed “genuine remorse”.
He added that the judge should take into account the long delay in the case – with the defendant not appearing in court until September last year.
Mr Bremridge said that Caine had used the time to tackle his problems, including heavy drinking, on his own initiative.
The barrister added that his family had used their savings to pay for his treatment at The Priory.
Judge Mousley handed Caine a fresh nine-month prison sentence but suspended it for two years.
He ordered that he have six-month alcohol treatment and 35 days of probation’s intensive Rehabilitation Activity Requirement.
Caine was also fined £1,000 for breaching his original suspended sentence.
The judge also ordered that his phones and computers be forfeited.