The comedian wants a new hearing on his 2016 petition of habeas corpus, which argued the proceeding should be dismissed because of his non-prosecution deal with the former District Attorney.

Bill Cosby's legal team is making another move to help the 81-year-old comedian avoid prison following his April conviction of aggravated sexual assault — and it's not just any ordinary motion.

Cosby stands convicted of sexually assaulting ex-Temple University employee Andrea Constand in 2004. Back then, the parties reached a settlement and the sitting Montgomery County District Attorney, Bruce Castor, agreed not to prosecute Cosby. After deposition testimony was unsealed, in which Cosby admitted to giving women quaaludes, current DA Kevin Steele moved full steam ahead with prosecution. Steele's motives have been criticized as purely political, particularly because his campaign ads attacked Castor for his decision not to prosecute and he announced Cosby's arrest the month after he was elected.

Now, Cosby's legal team is challenging Judge Steven T. O'Neill's motives and wants to take the case back to the very beginning. According to a motion filed Tuesday, Cosby wants O'Neill to recuse himself and overturn a key February 2016 ruling in which he found that Cosby's due process rights weren't being violated in prosecuting him despite the alleged non-prosecution agreement from Castor.

Cosby's attorneys claim that during a late-'90s political campaign between the two men, Castor learned that O'Neill had previously had a romantic relationship with one of his deputy district attorneys. Castor then required his DDA to publicly support him at a debate with O'Neill, which Cosby's attorneys say hurt the judge's performance. O'Neill lost and Cosby's team says that humiliation drove his grudge with Castor.

Castor was a key witness during a hearing on Cosby's motion to dismiss the case, and his attorneys argue that O'Neill should have disclosed his personal conflict and recused himself. Instead, he actually cross-examined the witness and ultimately rejected the testimony.

Camille Cosby on Tuesday issued a lengthy statement. "Mr. Castor testified under oath that when he was DA in 2006, he made a binding decision that because the evidence was weak, Mr. Cosby would never be prosecuted in this case, and that as a result of that decision, Mr. Cosby no longer had the right to remain silent and would be required to give a deposition in a civil lawsuit," she says. "That this judge would hide his bias and decide that his rival, the former DA, could not be trusted to give truthful testimony, shows that the judge let his own personal feelings override Mr. Cosby’s right to a fair trial." (Read it in full here.)

In a motion filed Tuesday, Cosby attorney Joseph P. Green Jr. argues it was "manifestly apparent" in the earliest days of the litigation that Castor's credibility would be a key factor in the outcome. Following a Feb. 2, 2016, hearing O'Neill found the ex-DA's testimony to not be credible.

"The Court made no disclosures, at any time before, during or after the hearing, that the Court had long been embroiled in a personal conflict with Mr. Castor that can only be described as nasty, including conduct by Mr. Castor directed at Judge O'Neil, that would cause any reasonable person, including any reasonable Judge, and a 'significant minority of the lay community,' to conclude that the Court could not possibly be impartial regarding Mr. Castor's credibility," writes Green.

A March 2018 Radar Online story tipped off Cosby's legal team to the alleged grudge and they began investigating the situation. They believe, according to the filing, that it was Castor himself who brought the story to the gossip site.

Cosby is asking O'Neill to vacate his February 2016 ruling, grant a new hearing on the petition of habeas corpus that maintained the proceeding should be dismissed based on Cosby's deal with Castor and recuse himself. (Read the full motion below.)