The gavels had fallen, the cases appeared closed:

Marsha Kay Esswein was found guilty of stabbing to death her 82-year-old husband in Riverside County.

Christopher James Lloyd was convicted in Orange County of knifing a man in a hotel room.

Roshawn Anthony Charles was found guilty in Los Angeles County of aggravated assault by a gang member.

Jonis Centeno was convicted in San Bernardino County of committing lewd acts on a 7-year-old child.

Except, it turned out, they weren’t closed at all. From 2010 through 2015 all of these convictions, and dozens more, were tossed out on appeal because of prosecutorial misconduct, that is, cheating by prosecutors to win in court.

Though it’s common for court cases to end with defendants or their lawyers claiming bad behavior by prosecutors, actual legal findings of prosecutorial misconduct – decisions reached by a judge and entered into the record – are rare. It is rarer still for justices – usually in the state Supreme Court or appellate court – to reverse convictions because of misconduct.

But a new study by Harvard Law School’s Fair Punishment Project shows Southern California ranks high in reversals in which misconduct by a prosecutor played a factor. And the embattled Orange County District Attorney’s Office has the state’s worst record based on population.

It’s not just Orange County prosecutors who run afoul of the law. The study found that Los Angeles County has the state’s fourth* worst record when it comes to prosecutorial misconduct producing reversals in court. Riverside and Los Angeles counties tied for second, while San Bernardino and San Diego counties tied for seventh.

Legal scholars say the study shows serious flaws in Southern California’s justice system.

“Reversals are an indication of a bigger problem. The case was so egregious that a court determines years later that it wasn’t a fair trial,” said Daniel Medwed, a professor at Northeastern University School of Law. “A high rate of reversals from a single office may be a sign of a problematic, overly aggressive prosecutorial culture in that organization.”

Prosecutorial misconduct can include withholding evidence from defense attorneys, misleading juries, participating in the presentation of false evidence by police and removing potential jurors on the basis of race.

Experts say it is difficult to prove misconduct and harder still to show the misconduct was not a “harmless error” that didn’t affect the outcome of the case. Though prosecutors make mistakes, and some prosecutors break or bend the rules, the process of reaching a misconduct finding involves a combination of research and dumb luck, according to legal experts.

“Most of the time, if there is a … violation, nobody finds out about it,” said Laura Fernandez, a research scholar and Senior Liman Fellow in residence at Yale Law School.

“You’re only ever seeing the tip of the iceberg.”

And sometimes it takes decades for the misconduct to surface.

Take the case of Los Angeles gang member Barry Glenn Williams. It took more than 30 years for a federal judge in 2016 to overturn Williams’ murder conviction and death sentence because the Los Angeles County prosecutor withheld the true name and address of a witness from the defense and failed to correct false testimony. Williams’ case was not included in the Harvard study.

The prosecutor in the Williams case, Carmen Trutanich, went on to serve as Los Angeles City Attorney from 2009 to 2013. Trutanich, 65, now faces discipline by the State Bar of California for allegedly cheating to win a conviction against Williams, accused in the fatal shooting of a bicyclist in the mid 1980s.

In Orange County, the overturned convictions add more heat to an office already under fire.

Orange County District Attorney Tony Rackauckas’ office is under investigation by the U.S. Department of Justice and the California Attorney General’s Office for allegations that prosecutors and police developed a network of jailhouse informants to illegally garner confessions from inmates. It is a civil rights violation to use informants against defendants who have attorneys and have been formally charged.

Orange County prosecutors also are accused of withholding favorable evidence from defense attorneys, especially evidence pertaining to informants.

Orange County’s “snitch scandal” has rocked the local justice system, prompting one judge to ban Rackauckas and his office from prosecuting the worst mass murderer in county history. Scott Dekraai, who pleaded guilty to murdering eight people in a Seal Beach shooting rampage, is now being prosecuted in the penalty phase by the state attorney general’s office. Superior Court Judge Thomas Goethals is poised to take the death penalty off the table for Dekraai because of concerns that informants were improperly used and informant-related documents were shredded.

At least six murder and attempted murder cases in Orange County have resulted in overturned convictions, lowered sentences and dropped charges because of problems with informants and the withholding of evidence. None of those cases involved official findings of intentional misconduct by prosecutors.

The Orange County Grand jury has declared the scandal “a witch hunt” and a “myth,” while appellate justices and Goethals say the improper use of informants in the county is real and systemic.

The scandal helped spur Harvard to study the rate of prosecutorial misconduct in Orange County and, to give that data some context, the rest of California. Harvard’s Fair Punishment Project also looked at DA offices in New Orleans, St. Louis and Memphis.

The study found Orange County had 24 misconduct findings from 2010 to 2015, and seven reversals in which misconduct was a factor. That amounts to more than one reversal a year. By comparison, the Orange County District Attorney’s Office completed 693 criminal trials in 2016.

While that ratio may be low, the stakes are high, according to Bennett L. Gershman, a professor at Pace Law School in New York and one of the nation’s leading experts on prosecutorial misconduct.

“To me, any reversal is a big deal,” said Gershman, a former prosecutor and author of two books on misconduct and judicial ethics. “I don’t think prosecutors make mistakes. I think they know what they are doing.

“If an appellate court reverses a case (because of) prosecutorial misconduct – any time – that’s a serious matter,” he added. “Finding misconduct is a laborious and a difficult pursuit.”

Michelle Van Der Linden, spokesperson for Rackauckas, said the Harvard study is flawed.

“Based on the fact the authors of this report are criminal defense attorneys, who are typically anti-law enforcement, they didn’t contact our office for any information, but simply relied on news articles versus actually doing their own research, makes their findings non-credible,” Van Der Linden said. When told the researchers based the study on appellate court rulings, Van Der Linden said she stood by her statement.

Gershman said the reversals, coupled with the informant scandal, might offer insight into the inner workings of the Orange County District Attorney’s Office. “The jailhouse scandal may be indicative of the ethos, the culture of prosecutors in (that) county.”

Professor Medwed, who wrote the book “Prosecution Complex: America’s Race to Convict and Its Impact on the Innocent” – and who serves as a legal adviser for the Fair Punishment Project – said Orange County’s seven reversals in six years is problematic.

“Even if seven cases in the abstract does not seem large, in the context of reversals for prosecutorial misconduct, it’s quite significant,” he said. “It is very alarming.”

Misconduct also can be a key factor in a guilty verdict.

In the case of Christopher James Lloyd, the man convicted in the knife attack, an Orange County prosecutor told the jury that a verdict of “not guilty” would mean Lloyd didn’t do it, playing on a common misconception. In truth, according to the appellate opinion, a “not guilty” verdict could also mean that the prosecutor did not prove his case beyond a reasonable doubt.

“Had the prosecutor not misstated the law, there is a reasonable probability the jury would have returned a more favorable verdict for defendant,” the ruling said.

Around Southern California, the Fair Punishment Project found 78 misconduct findings in Los Angeles County during the six-year-study period, with 22 reversals in which misconduct was a factor. There were 32 findings of misconduct in Riverside County and four reversals; 11 findings in San Diego County with three reversals, and nine findings in San Bernardino County with two reversals. Statewide, the study found 269 findings of misconduct with 54 reversals in which misconduct was a factor.

In Riverside County, justices ordered a new murder trial for Marsha Kay Esswein because the prosecutor, Christopher R. Ross, told jurors in his opening statement that the killing was premeditated – but didn’t provide evidence to back that statement during trial.

Ross, who left the district attorney’s office, was referred to the state bar for potential discipline.

In the case of alleged gang member Roshawn Anthony Charles, the Los Angeles County prosecutor improperly introduced evidence that an accomplice pleaded no-contest to similar charges. Appellate justices later determined the tactic tainted the jury. Charles later pleaded no-contest before he could be retried.

The Los Angeles County District Attorney’s Office declined to comment.

In the case of Jonis Centeno, who was accused of child molestation, a San Bernardino County prosecutor presented improper evidence intended to sway the jury.

“Given the closeness of the case and the lack of any corrective action, there is a reasonable probability that the prosecutor’s argument caused one or more jurors to convict defendant based on a lesser standard than proof beyond a reasonable doubt,” said the state Supreme Court in the Centeno ruling.

By the time justices reversed his conviction, Centeno had already served his sentence.

Legal experts say prosecutors are rarely punished for legal misconduct. In fact, most appellate rulings don’t even name the offending prosecutor. A California law enacted last year could send prosecutors to jail for intentionally withholding or falsifying evidence. However, scholars says, it is hard to prove the misconduct was done willfully.

The State Bar of California also has initiated an ethics rule that disciplines prosecutors who do not hand over evidence that they know is beneficial to the defense. An Orange County prosecutor, Sandra Lee Nassar, is facing discipline by the bar for allegedly failing to disclose evidence in a 2013 child abuse case in order to obtain a strategic advantage.

“Right now, there’s an argument that prosecutors are being aggressive. And, in the back of their minds, the chance of reversal is really low (they’re thinking) ‘let’s take that chance,’” Medwed said. “Many (prosecutors) have convinced themselves they aren’t doing the wrong thing. ‘The guy’s guilty. I don’t think it violates (disclosure laws). I’m going to go for it.”’

“Sometimes it’s for the broader good, like protecting the public, putting a bad guy behind bars,” Medwed added.

A 2011 Yale Law journal said because penalties are so rare, and the stakes so high, prosecutors are routinely tempted to cheat. The journal wrote: “Knowing that ‘minor’ misconduct is unlikely to jeopardize a conviction on appeal, prosecutors may be more likely to bend the rules in the pursuit of victory.”

In addition to looking at Rackauckas, the Harvard study also looked at other troubled chief prosecutors in New Orleans, Memphis and St. Louis.

“What we found is noteworthy. These four prosecutors, and the people who work with them, have repeatedly violated their constitutional and ethical duties, shattering the lives of the defendants and their families,” said the report.

In New Orleans, elected District Attorney Leon Cannizzaro came under fire for issuing fake subpoenas to trick reluctant witnesses to testify. According to the Fair Punishment Project, Cannizzaro’s prosecutors also repeatedly hid evidence showing that his office had made deals with informant witnesses, and failed to turn over crucial materials to defense lawyers in a timely manner.

Cannizzaro’s office had the second worst ranking in Louisiana for reversals per capita in which prosecutorial misconduct played a role.

The report also said city of St. Louis Circuit Attorney Jennifer Joyce defended a prosecutor in her office who had at least 25 misconduct allegations. Joyce’s office was ranked fourth per capita in Missouri for reversals in which prosecutorial misconduct was a factor.

In Memphis, Shelby County District Attorney General Amy Weirich was privately reprimanded after the Tennessee Supreme Court concluded she withheld key evidence from the defense in a murder trial, according to news accounts and the Harvard report. Weirich’s office was ranked sixth per capita in Tennessee for reversals in which prosecutorial misconduct played a role.

Editor’s note: An earlier version of this story included different rankings for Orange, Los Angeles, Riverside and San Bernardino counties, when measured by the Fair Punishment Project. The rankings reflect changes issued by Harvard following a review of the data.