Facebook will overhaul its ad-targeting systems to prevent discrimination in housing , credit and employment ads as part of a legal settlement.

For the social network, that’s one major legal problem down, several to go, including government investigations in the U.S. and Europe over its data and privacy practices.

The changes to Facebook’s advertising methods —which generate most of the company’s enormous profits — are unprecedented. The social network says it will no longer allow housing, employment or credit ads that target people by age, gender or zip code. Facebook will also limit other targeting options so these ads don’t exclude people on the basis of race, ethnicity and other legally protected categories in the U.S., including national origin and sexual orientation.

The social media company is also paying about $5 million to cover plaintiffs’ legal fees and other costs.

Facebook and the plaintiffs — a group including the American Civil Liberties Union, the National Fair Housing Alliance and others —called the settlement “historic.” It took 18 months to hammer out. The company still faces an administrative complaint filed by U.S. Department of Housing and Urban Development in August over the housing ads issue.

Two top Facebook execs leave as Zuckerberg prepares new focus

What’s not yet clear is how well the safeguards will work. Facebook has been working to address a slew of social consequences related to its platform, with varying degrees of success. Last week, it scrambled to remove graphic video filmed by a gunman in the New Zealand mosque shootings, but the footage remained available for hours on its site and elsewhere on social media.

Earlier in March, CEO Mark Zuckerberg announced a new “privacy-focused vision” for the company to focus on messaging instead of more public sharing — but he stayed mum on overhauling Facebook’s privacy practices in its core business.

Watching Facebook actions

Galen Sherwin, senior staff attorney at the ACLU and the group’s lead attorney on its suit, praised the settlement as “sweeping” and said she expects it to have ripple effects through the tech industry.

Others will be watching.

“Kieley Taylor, global head of social at WPP PLC’s media-agency conglomerate GroupM, said she would keep an eye on how the changes affect the efficacy of Facebook’s lookalike tool for clients in sectors such as financial services,” The Wall Street Journal reported.

Dan Goldstein, owner of Page 1 Solutions, a full-service digital marketing agency, said in a statement that the agreement is positive move for consumers and companies, but the geo-targeting rules could create some issues.

“Ultimately, I think this is a positive development for brands and consumers alike. The most successful Facebook ad campaigns foster genuine connections with customers who exemplify buying behaviors that make them likely to convert,” Goldstein said.

“Brands regardless of industry should be striving to understand who their customers are at a deeper level than categorization by gender, ‘ethnic affinity,’ etc. can provide. This will require more analysis and greater creativity on the part of advertisers (especially those in highly regulated industries), but the restrictions created by a loss of ad categories should make it possible for businesses to see a better return on paid Facebook campaigns.”

Facebook agreed to let the groups test its ad systems to ensure they don’t enable discrimination. The company also agreed to meet with the groups every six months for the next three years, and is building a tool to let anyone search housing-related ads in the U.S. targeted to different areas across the country.

Other issues

Discrimination hasn’t been Facebook’s only problem with ad targeting. It’s taken fire for allowing advertisers to target groups of people identified as “Jew-haters” and Nazi sympathizers. It’s also still dealing with fallout from the 2016 election, when, among other things, Facebook allowed fake Russian accounts to buy ads targeting U.S. users to stir up political divisions.

One of the complaints said that Facebook violated the Fair Housing Act because its targeting systems allow advertisers to exclude certain audiences, such as families with young children or disabled people, from seeing housing ads. Others alleged job discrimination, with ads being shown to men but not women in traditionally male-dominated fields, or only to younger users.

As part of the changes, advertisers who want to run housing, employment or credit ads will no longer be allowed to target people by age, gender or zip code. Facebook will also limit the targeting categories available for such ads. For example, such advertisers wouldn’t be able to exclude groups such as “soccer moms” or people who joined a group on black hair care.

Facebook pivots to privacy, but can Zuckerberg make the strategy work?

Endlessly customizable ad targeting is Facebook’s bread and butter. The ads users see can be tailored down to the most granular details — not just where people live and what websites they visited recently, but whether they’ve gotten engaged in the past six months or share characteristics with people who have recently bought a BMW, even if they have never expressed interest in doing so themselves. It’s how they company made $56 billion in revenue last year.

“There is a lot of pressure on Facebook and its ability to target ads,” said eMarketer analyst Debra Aho Williamson. “And a lot of scrutiny on what it should and shouldn’t be able to do. This is just one more example of that.”

Last year, amid concerns over how it collects user data and in preparation for tighter privacy regulation in Europe, Facebook shut down an advertising product that allowed marketers to use data from people’s offline lives to target them on Facebook. Williamson said this caused some advertisers to change their plans. While so far Facebook’s ad revenue has not suffered, uncertainty over how well businesses will be able to target users in the future could spook the advertisers.

Sandberg: Work far from over

“They will start to think, ‘are there any other types of targeting that are at risk?'” she said.

In a brief interview with The Associated Press, Facebook chief operating officer Sheryl Sandberg declined to say whether the changes will hurt the company’s advertising revenue. The most important thing, she said, was to protect Facebook’s users from discrimination.

“Today’s changes mark an important step in our broader effort to prevent discrimination and promote fairness and inclusion on Facebook,” she said in a blog post Tuesday . “But our work is far from over.”