The tragic murders of five Dallas police officers happened in a city where cops were making strides to improve relations with African-American residents.
Headed by a hard-charging black police chief named David Brown, the Dallas Police Department insisted on keeping the public informed whenever police shot a suspect and put into practice lessons learned in the wake of the fatal 2014 police shooting of Michael Brown in Ferguson, Missouri.
Related: How The Dallas Ambush Unfolded
"We try our best to be transparent," the chief wrote in The Dallas Morning News days after Michael Brown's death.
Brown recounted the steps his force took to tamp down tensions after an officer-involved shooting in 2012. "And I can tell you that not all cops like it. It does open us up to criticism, threats and exposure of every mistake we make," Brown said. "But it's the right thing to do."
The shooting in Dallas occurred near the end of a demonstration protesting the use of police force against African-Americans following recent shootings of black men in Louisiana and Minnesota.
The gunman in the Dallas ambush told police negotiators he was upset about recent police shootings and "stated he wanted to kill white people, especially white officers," Brown said. The city's mayor said Friday the gunman was the lone shooter.
Dallas Mayor Mike Rawlings could not hide his frustration Friday.
"This police department trained in de-escalation far before cities across America did it," he said. "We're one of the premier community policing cities in the country, and this year we have the fewest police officer-related shootings than any large city in America."
Brown is no stranger to tragedy. The Washington Post reported his police academy classmate and former partner Walter Williams was killed on the job in 1988. His younger brother, Kelvin, was killed in 1991 by drug dealers.
But perhaps Brown's greatest loss came in June 2010, just seven weeks after he took over the Dallas police force. His troubled son, also named David, shot and killed a suburban Dallas police officer and a passersby before he too was killed.
As chief, Brown immediately began reforming the department he had served in for 27 years.
He equipped them with body cameras. He adopted a community-oriented program. He revamped training on the use of lethal force. He introduced new guidelines for reporting violent encounters with cops. And he made it department policy to bring in the FBI civil rights division whenever there was a police involved shooting.
When one of his officers was caught on dash cam video punching and pepper-spraying a handcuffed prisoner, Brown fired him. The former officer, Quaitemes Williams, was later convicted of official oppression and sentenced to 180 days in jail.
The number of use-of-force complaints against the Dallas police department dropped by 64 percent between 2009 and 2014, the Dallas Morning News reported. So did the number of assaults on police officers, and the number of police shootings.
As an added bonus, the number of murders in Dallas fell in 2014 to 116 from the previous year's 143.
"This is the most dramatic development in policing anywhere in the country," Brown boasted in November to the Morning News. "We've had this kind of impact basically through training, community policing, and holding officers accountable."
Chuck Wexler of the Police Executive Research Forum agreed.
"That's what police departments need," he told the paper. "They don't need training in silos: One day about the law, one day about firearms, one day about crisis intervention."
Community activists like Walter "Changa" Higgins of Dallas Communities Organizing for Change said police have made overtures to the African-American community, but said the department needs to do more.
"On a very surface level there has been a strong outreach effort by the Dallas Police Department, particularly to the African-American community," Higgins told NBC News. "A lot of great marketing and PR that looks great from the outside. It makes the Dallas Police look like the model of what it should be."
But Brown has also put into place a 72-hour rule that allows officers involved in a shooting "to get their stories straight" before they are questioned, said Higgins.
"Other big city departments have this policy," added Higgins. "The most egregious thing is that officers can use that time to read witness statements and review footage."
Also, said Higgins, for all of Brown's claims of transparency "the reality is different." Higgins criticized what he called a nine-month delay in releasing a video after a mentally ill man was shot by a Dallas police officer in June of 2014.
Also, some of Brown's moves have upset the ranks.
Faced with a big spike in crime this year, Brown responded by moving hundreds of officers to different shifts and others to task forces targeting specific neighborhoods.
Brown's backers on The Black Police Association turned against him and called for his ouster, the Morning News reported.
Brown was not deterred.
"I just have to focus on doing the job for the citizens of Dallas," he said.