Hillary Clinton and Bernie Sanders sparred over their record on guns in a city wounded by one of the worst incidents of gun violence in America as criminal justice — particularly as it is applied to the black community — was front and center in the Democrats’ last debate before the Iowa caucuses.

In a night that bounced around from guns to Wall Street, global warming to foreign affairs, the Emanuel AME Church shooting emerged as an early backdrop while bringing out some of the nastiest displays between the three candidates on stage at the Charleston Gaillard Center.

Clinton accused Sanders of being “a pretty reliable vote for the gun lobby,” pointing to the Vermont senator’s votes against the Brady Bill and for what today is known as the “Charleston loophole.”

She noted that it was just this weekend that Sanders changed his position to now support efforts that would strip the legal immunity that gun manufacturers have in gun deaths.

“He voted against the Brady Bill five times,” Clinton charged. “He voted for what we call the Charleston loophole,” she said, adding, ”He voted to let guns go on Amtrak, (and for) guns to go into National Parks.”

Sanders countered that Clinton was being “disingenuous” in describing his record, pointing to his D-minus rating from the National Rifle Association.

“I have supported from day one an instant background check to make certain that people who should not have guns do not have guns,” he said. “And that includes people with criminal backgrounds, people who are mentally unstable. I support what President (Barack) Obama is doing in terms of trying to close the gun show loopholes.”

The third candidate in the debate, former Maryland Gov. Martin O’Malley, also tried to play up his anti-gun credentials, saying he’s the only one of the three pursuing the party nomination who actually signed gun restricting laws.

“We did pass in our state comprehensive gun safety legislation,” he said. “It did have a ban on combat assault weapons, (and) universal background checks,” he said. “And you know what? We did not interrupt a single person’s hunting season.”

The “Charleston loophole” emerged as an issue Sunday because it was how admitted Emanuel AME shooter and self-proclaimed white supremacist Dylann Roof was able to complete his store purchase of a .45-caliber Glock handgun. Before Roof took the pistol home, he was required to submit to an FBI background check. But it failed to uncover his past drug abuse because of a paperwork error.

The drug issue should have disqualified him, but a three-day waiting period lapsed while the FBI was still looking for records of the drug arrest, so the store was allowed to sell him the gun. Roof is charged with murdering nine parishoners at the church during Bible study in June.

Beyond the dueling over guns, Sunday’s debate, which was aired nationally by NBC News, saw some of the fiercest exchanges between Clinton and Sanders, who are neck and neck in Iowa, which votes Feb. 1.

Sanders stuck to his theme that Wall Street has too much influence in Washington as he repeated his assertion that Clinton has a history of supporting banking interests.

“The first difference is, I don’t take money from big banks,” he said.

But they agreed that the criminal justice system in America needs to be reformed, saying black citizens more often than whites are bearing the brunt of the inequities.

Clinton pointed to statistics indicating that one in three black males are incarcerated. “What would we be doing if it was one out of three white men?” she said.

Sanders said that whenever someone is killed while in police custody the U.S. Justice Department should be called in to investigate. He expressed support for police who are doing a difficult job under difficult conditions but for any cop caught breaking the law there has to be consequences under the law.

O’Malley also contrasted the Democrats with the Republicans, saying the Democratic side has a line up that “actually believe in science.” Forecasting into the future, he said the country hasn’t “had a new agenda for America’s cities since Jimmy Carter.”

O’Malley called for committing to “a 100 percent clean electricity grid by 2050,” something he said could create millions of jobs.

Clinton and Sanders also fought over health care reform. Sanders on Sunday released a plan for a government-run single-payer plan as he built on his campaign stump call for health care “for every man, woman and child as a right.”

Clinton, however, said more tinkering with President Barack Obama’s Affordable Care Act could open the door for more attacks by Republicans against it.

“With all due respect, to start over again with a whole new debate is something that would set us back,” she said.