NEW YORK (AP) — Facebook is apologizing to drag queens and the transgender community for deleting accounts that used drag names like Lil Miss Hot Mess rather than legal names such as Bob Smith.

The world’s biggest online social network caught heat recently when it deleted several hundred accounts belonging to self-described drag queens, other performers and members of the lesbian, gay, bisexual and transgender community. Facebook has long required its users to go by their “real names” on the site for security purposes, to stand out from other social networks and so it can better target advertising to people. Now, the company says the spirit of its policy doesn’t mean a person’s legal name but “the authentic name they use in real life.”

"For Sister Roma, that’s Sister Roma. For Lil Miss Hot Mess, that’s Lil Miss Hot Mess," Chris Cox, Facebook’s vice president of product wrote in a blog post Wednesday.

Though the real names policy isn’t changing, the way Facebook enforces it might.

Last month, the company suggested that performers such as drag queens have other ways of maintaining their stage identities on the site, such as creating pages that are meant for businesses and public figures. But a fan page is not the same as a regular Facebook account and users were not happy with the suggestion.

While standing by the real names policy on Wednesday, Cox said “we see through this event that there’s lots of room for improvement in the reporting and enforcement mechanisms, tools for understanding who’s real and who’s not, and the customer service for anyone who’s affected.”

Cox also gave some background on why so many accounts with drag names and other stage names suddenly started getting deleted.

"An individual on Facebook decided to report several hundred of these accounts as fake," he wrote. "These reports were among the several hundred thousand fake name reports we process every single week, 99 percent of which are bad actors doing bad things: impersonation, bullying, trolling, domestic violence, scams, hate speech, and more — so we didn’t notice the pattern."

A coalition of protesters praised Facebook for agreeing to build new tools. “The drag queens spoke and Facebook listened!” San Francisco Supervisor David Campos said in a statement. “Facebook agreed that the real names policy is flawed and has unintentionally hurt members of our community. We have their commitment that they will be making substantive changes soon and we have every reason to believe them.”

Sister Roma, a member of the Sisters of Perpetual Indulgence who led the protests, joined in the praise. “I always knew that Facebook would do the right thing,” she said in a statement. “The people who work at Facebook live in San Francisco and are part of our community. You can’t be a San Franciscan and not love drag queens. I’m just happy I’ll have my name back.”

Still, it’s unclear how Facebook will accommodate performers like these in the future. Facebook’s real-name policy, even if it isn’t universally enforced, is still one of the site’s defining features. It’s part of the pitch the company makes to advertisers — these are real people — and as Cox notes, it offers helpful protections against abuse and harassment online. “It’s the primary mechanism we have to protect millions of people every day, all around the world, from real harm. The stories of mass impersonation, trolling, domestic abuse, and higher rates of bullying and intolerance are oftentimes the result of people hiding behind fake names, and it’s both terrifying and sad,” Cox wrote.

Cox says the company is “building better tools for authenticating the Sister Romas of the world while not opening up Facebook to bad actors. And we’re taking measures to provide much more deliberate customer service to those accounts that get flagged so that we can manage these in a less abrupt and more thoughtful way.” The Verge has asked Facebook to clarify what tools it is developing.