Bill Cosby's effort to erase his conviction for sexual assault went before a Pennsylvania appellate panel Monday for a hearing focused on whether the trial judge made prejudicial errors or properly allowed testimony about Cosby's "decades-long pattern" of sexual misconduct.

According to the Associated Press, the panel of three judges questioned why Cosby's legal team never got a supposed 2005 non-prosecution agreement in writing or approved by a judge. The issue is one of several raised by Cosby's lawyers in his appeal.

When he was tried in June 2017 and in April 2018, Cosby argued that a previous district attorney had agreed not to prosecute him on sexual molestation charges because of a lack of evidence. But Cosby's trial attorneys could provide no written proof of this agreement, other than a prosecutor's press release at the time, and his lawyer in 2005 had died.

Superior Court Judge John T. Bender suggested Cosby's lawyer failed to follow normal practice and get this agreement on the record. "This is not a low-budget operation. … They had an unlimited budget," Bender said. "Could it be they knew this was something the trial court would never have allowed?"

Besides, added Judge Carolyn Nichols, "How can the elected district attorney bind that office in perpetuity?"

During both trials, Cosby's defense lawyers argued that Cosby relied on the promise he would not be prosecuted before giving a deposition in a 2005 related civil lawsuit acknowledging he obtained drugs to give to women he sought for sex – an admission that proved incriminating when the deposition was unsealed a decade later and introduced as evidence against him at his trials.

Cosby wasn't prosecuted in 2005 but he was arrested and charged in connection with the same 2004 encounter a decade later after dozens of other accusers came forward.

There is a lot riding on this hearing for Cosby: Under Pennsylvania law, the only guaranteed appeal venue for a defendant is with the Pennsylvania Superior Court in the state capital of Harrisburg.

At an appeals hearing, typically each side gets about 15 minutes to make its case – but that counts the questions the judges may ask. Interruptions can be expected, shortening even more the time each side has to argue.

Cosby, 82, is being represented by his appellate team, Kristen Weisenburger and Barbara Zemlock, according to his spokesman, Andrew Wyatt.

The Commonwealth, specifically Montgomery County District Attorney Kevin Steele, is represented by Robert Falin, chief of the district attorney's appellate unit.

The judges will not issue a decision right away, and it could be months before they issue a ruling.

If the decision goes against Cosby – meaning the three-count guilty verdict and the three-to-10 year sentence is affirmed – then Cosby stays in his prison cell near Philadelphia and his lawyers can try to persuade the Pennsylvania Supreme Court to hear his appeal.

But the high court doesn't have to take the case and there is no guarantee it would.

The stakes also are high for the prosecution side, which includes #MeToo movement and anti-rape activists, who hailed Cosby's conviction as retribution for the five dozen other women who have accused him of sexual misconduct dating back to the mid-1960s. The Rape, Abuse & Incest National Network (RAINN) filed a friend-of-the-court brief supporting the conviction.

The Cosby case is frequently referred to as the first celebrity trial of the #MeToo era: Although his first trial in June 2017 took place before the movement surged in November 2017, his second trial took place nearly a year later.

But in fact, so far Cosby is the only celebrity convicted post-#MeToo: The New York sexual assault case against fallen Hollywood mogul Harvey Weinstein is still pending, as are four sets of sex-crime charges in three states against R&B star R. Kelly. And the Massachusetts groping case against Oscar winner Kevin Spacey collapsed last month.

The Cosby appeal, however, will focus on something more nuts-and-bolts legalistic, one that comes up in scores of noncelebrity criminal cases: Was his trial in Montgomery County, Pennsylvania, conducted properly or were there mistakes that produced an unfair result that should be overturned?

To recap: Cosby was convicted in April 2018 (his first trial ended in a hung jury) of three counts of drugging and molesting former Temple University employee Andrea Constand at his suburban Philadelphia home in 2004. He was sentenced in September and has been locked up in a state prison ever since, despite repeated efforts to be released while his case is on appeal.

Cosby says his encounters with Constand and with other accusers were consensual.

His appellate brief features a litany of alleged errors by trial Judge Steven O'Neill, who also presided over his first trial. Perhaps the most important: O'Neill allowed five other accusers to testify about separate and uncharged crimes they say Cosby committed against them in the past, to establish a pattern of "prior bad acts" to bolster Constand's accusations.

O'Neill, who allowed only one such accuser to testify at the first trial, also filed a brief with the appellate court in which he argued, through case law and precedent, that none of the "errors" Cosby alleged were actually errors. In an earlier opinion, he wrote that he allowed the five other accusers to testify because their accounts had "chilling similarities" that pointed to a "signature" crime.

Prosecutors said they chose women to testify whose accounts showed Cosby had a criminal "pattern." Bender seemed to agree, interrupting defense arguments that their stories had significant differences.

"The reality of it is, he gives them drugs and then he sexually assaults them," he said. "That's the pattern, is it not?"

Prior-bad-acts witnesses could be increasingly crucial in other sex-crime cases and in other states where they are allowed, as long as their probative value outweighs their prejudicial effect.

Cosby's lawyers quote case law in arguing that such testimony was "extraordinarily prejudicial," to the point that it "predisposed" jurors to believe he was guilty, thus effectively stripping him of the presumption of innocence.

In the Commonwealth's appellate brief, prosecutors echoed O'Neill's argument that such testimony is permissible under Pennsylvania law when it demonstrates a "signature" crime.

"There was no coincidence here. To the contrary, defendant's drug-facilitated sexual assault of Constand was the culmination of a decades-long pattern of behavior evidenced by his prior bad acts towards the five witnesses sufficiently 'distinctive and so nearly identical as to become the signature of the same perpetrator,' " the prosecutors wrote, quoting from case law on the issue.

Cosby's appeal also raises other issues about his trial, including the supposed binding agreement with a previous district attorney in 2005 that he would never be charged in the Constand case because of insufficient evidence.

Cosby also argues that O'Neill should have recused himself from the Constand case because his supposed "political feud" with former district attorney Bruce Castor meant O'Neill was "biased" against Castor when he testified as a defense witness at a pretrial hearing.

And Cosby also challenged O'Neill's decision to allow testimony from a 2005 deposition to be introduced at the trials, in which Cosby acknowledged acquiring quaaludes in the 1970s to give to other women before sex.

Contributing: The Associated Press

.