Separating music and club culture from drug use isn’t easy. Just ask the owners of Fabric, the fabled London nightclub that had its license revoked on Wednesday by city authorities concerned about drug use at the venue. Or the organizers of Electric Daisy Carnival, Hard Summer and other events hammered by headlines of festival goers dying of drug use.

In many of these cases, the primary drug involved is ecstasy or various chemical concoctions sold as ecstasy. Though considered less addictive than cocaine and heroin, ecstasy is getting a bad reputation from politicians who are targeting the drug specifically. The most obvious example is the Reducing Americans’ Vulnerability to ecstasy (or RAVE) Act, which Congress passed in 2003 as the Illicit Drug Anti-Proliferation Act.

Club closures or law enforcement aside, there’s a third option that’s quietly gaining momentum -- using education and advocating for harm reduction measures to avert ecstasy-related tragedies.

Know what you’re taking. In a novel experiment three years ago, London’s biggest nightclub, Warehouse Project, invited a criminology researcher from nearby Durham University to come once a month and test drugs found at the venue, either confiscated by authorities or contributed anonymously. If the researcher spotted a worrisome ingredient, she notified club managers, and messages would be sent out on social media and LED signs at the club to warn customers. Throughout Europe, on-site testing of drugs is commonplace, said Adam Auctor, founder of Bunk Police, a drug testing service based in Denver, Colo., that started testing in Europe this year.

In the U.S., testing at venues is far less common. DanceSafe and Bunk Police offer drug testing kits at clubs and events in North America. But because venues and promoters don’t want to run afoul of the Illicit Drug Anti-Proliferation Act that bans “maintaining a drug involved premises,” most refuse to allow these drug testing services on site since that can be perceived by prosecutors as encouraging drug use.

DanceSafe still attends a handful of events to provide free testing where they are permitted, but the events are mostly smaller and more loosely organized than the major festivals organized by corporate promoters who are more cautious about the liability, said Mitchell Gomez, national outreach director for DanceSafe, a non-profit organization based in Denver. Bunk Police no longer does real-time testing, Auctor said, but they still come to events to sell testing kits at a discounted price, though not always with the permission of event organizers.

Both groups sell drug testing kits online for between $20 for a single spot test, to $150 for a 60-test kit. Gomez cautions that the tests are limited in what they can reveal about a drug. While these tests can show whether the drug in question contains MDMA or cathinone (sold as “bath salts”), it often can’t tell you if there are adulterants or other additives, he said. Gomez dreams of being able to send in a full-fledged lab for real-time testing, but until federal drug laws are amended, he doesn’t see that happening.

“On the street, it can be hard to get pure compounds,” said Dr. Itai Danovich, chairman of the Department of Psychiatry and Behavioral Neurosciences at Cedars-Sinai Medical Center in Los Angeles. “With every step in the distribution chain, there tends to be cutting.”

Both Gomez and Auctor believe that key to implementing measures to prevent medical emergencies lies with amending the Illicit Drug Anti-Proliferation Act to explicitly allow promoters and venue owners to take steps to reduce harm from drug use. Dede Goldsmith, whose daughter died in 2013 of hyperthermia at a music festival after taking ecstasy, is among the leading advocates of changing the law because “it is preventing the implementation of common sense safety measures at these events.” As of this week, Goldsmith gathered more than 16,300 signatures through her online site.

“There’s no such thing as safe drug use,” said Gomez. “But there are ways we can mitigate risk by educating people about what they’re taking and by providing conditions that make it less likely to go south.”

To avoid medical emergencies it’s good to understand how the drug affects the body in the first place. Chemically, ecstasy in pure form is 3,4-methylenedioxy-methamphetamine, or MDMA. But there are variants of ecstasy on the market, and the amount of MDMA in these drugs is highly variable.

Gomez, whose organization has been testing drugs for their chemical components at dance events for 17 years, estimated that about 40 percent of the drugs sold today as ecstasy is actually methylenedioxypyrovalerone, methylone or mephedrone, sold on the street as “bath salts.” But about half of the samples tested by DanceSafe contain mostly MDMA, up from as low as 20 percent a few years ago as key ingredients for synthesizing it have become easier to acquire, he said.

Once it enters your body, MDMA enters your bloodstream and starts making its way to your brain. After it sneaks past the blood-brain barrier meant to protect your brain from neurotoxins, MDMA triggers the release of three neurotransmitters: dopamine, norepinephrine and serotonin, says Dr. Danovich. Like taking an orange and squeezing all the juices out.

Dopamine, associated with the pleasure and reward response, is responsible for the euphoria and energy that come with taking MDMA. Norepinephrine is an adrenaline that jacks up your heart rate and blood pressure. Meanwhile, serotonin creates a sense of well being, happiness and emotional binding.

In most cases, the effect lasts three to six hours. After that, many people get “depletion syndrome,” according to Danovitch. “It’s the crash. People feel low, irritable, depressed, have difficulty sleeping, feel anxious and have trouble focusing.”

Most of the time, the immediate, unwelcome health effects end there. In some instances, however, things can go badly wrong. Among the potentially catastrophic reactions are hyperthermia, rhabdomyolysis, organ failure, and severe anxiety or panic attacks, said Cathy Lee Rogowski, an emergency room physician in San Diego who has seen many of these symptoms and more.

The most pernicious long-term effect is brain damage. Because MDMA has only been in popular use as a recreational drug since the mid-'80s, researchers are just starting to understand how it affects the brain in the long-term. But there’s increasing evidence to support the likelihood that chronic use of ecstasy causes lasting brain damage.

One of the ways it damages the brain has to do with how the body tries to deal with the artificial flood of neurochemicals triggered by MDMA.

“If there’s too much neurotransmitters for the body to handle in the way it typically metabolizes those chemicals, the body uses a secondary pathway,” one that can leave toxic metabolites that accumulate over time, said Dr. Jeffrey Lieberman, Chairman of Psychiatry for the Columbia University Medical Center at NewYork-Presbyterian Hospital. The danger is that these toxic metabolites have the potential to destroy brain cells in a way that’s similar to how Parkinson’s Disease works, Lieberman said.

In an article -- “Human psychobiology of MDMA or ‘ecstasy’: an overview of 25 years of empirical research” -- published in the journal Human Psychopharmacology, Andrew C. Parrott of Swansea University’s Department of Psychology reported significant memory deficits and impairment on a range of cognitive tasks including “executive processing, logical reasoning, problem solving, and emotional intelligence.”

For adolescents and young adults, the long-term consequences are unknown. “The brain is not fully developed until you are in your mid-20s and early 30s,” Lieberman said. “There’s very little research on younger brains. Presumably there is a differential effect, but we just don’t know.”

The risk is even greater when it comes to pregnant women who take MDMA. In a 2012 study by Lynne Singer, et al., infants of mothers who took MDMA while pregnant had significantly poorer motor quality scores at 4 months of age. It will likely be years before researchers are able to find out how MDMA will affect these children over the long term.

While ecstasy is often called the “love drug,” it’s psychological effects are not always positive. In his review of 25 years’ worth of medical research on MDMA, Parrott concluded that “MDMA is essentially a mood intensifier” that can also magnify negative emotional states as well as positive. That’s not surprising when you consider the fact that MDMA is often classified as a hallucinogen, with effects similar to that of LSD.

When combined with other drugs, the outcome can be fatal. Emily McCaughan had taken a combination of MDMA and gamma-hydroxybutyric acid (or GBH) before she told friends that she was being followed, then jumped from the 20th floor of her Las Vegas hotel to her death in 2012. Kyle Haigis died in 2011 after he began acting irrationally, jumping out of a moving car and was struck by a passing semi.

The most common issue is excessive body heat, or hyperthermia. Serotonin, which helps regulate core temperature through the hypothalamus, acts as the body’s thermostat. “Serotonin enervates the hypothalamus,” Lieberman said. “It’s like setting the temperature on your thermostat higher.”

At the same time norepinephrine, the second neurotransmitter released into your brain by MDMA, causes you to feel energized, so you wind up dancing and moving a lot more. This creates even more heat in your body. Now add a stuffy or hot environment such as a poorly ventilated nightclub or a baking hot festival ground, and your body soon has difficulty cooling down. What’s wrong with that? Lots.

Excess body heat causes muscle cells to die. The muscles are also stressed out by the surplus adrenaline pumping through the body, thanks to the norepinephrine released by MDMA. Muscles tense and go rigid in preparation for the fight-or-flight response triggered by the adrenaline. People who take ecstasy often report that their jaws clench. The tension, if constant, leads to damage of the muscle fibers, called rhabdomyolysis.

The muscle soreness reported by many the day after taking ecstasy is likely a mild case of rhabdomyolysis.

Sustained rhabdomyolysis is problematic because it can suddenly become a runaway train that leads to organ failure.

When muscle cells die, they release a number of byproducts into the blood, including potassium ions, phosphate ions, myoglobin, creatine kinase and uric acid. “Your kidney tries to filter out these chemicals,” said Lieberman. “But your blood to become too viscous with the stuff. It’s like sludge, and it clogs up the kidneys.”

Meanwhile, the excess uric acid can form crystals in the tubules of the kidneys, further compromising the kidneys. “When that starts, it’s difficult to stop,” Lieberman said. “When the muscles die, they release these substances into the bloodstream. There’s no way to reverse that once they’re in the bloodstream. It can all happen very quickly, within a few hours.”

Though not extremely likely, heart failure can occur if there is a pre-existing heart condition that worsens when MDMA adds to the load. In six of the 24 ecstasy-related deaths reported by the Los Angeles Times, the heart went into cardiac arrest.

“Your body can’t tolerate a fast heart rate for too long,” Rogowski said. “It will burn out.”

Chemically, MDMA is closely related to methamphetamine, a potent stimulant. “Everything speeds up,” Rogowski said. “But your heart actually doesn’t function efficiently when it’s vibrating that fast, and the rest of your body doesn’t get the oxygen it needs.”

Another possible long-term effect of prolonged ecstasy use is acute hepatitis and liver failure. “You can overwhelm the liver’s ability to break down MDMA, leading to acute hepatitis” said Danovitch.

Now that you know how MDMA affects your body and what can go wrong, there are things you can do to reduce the risk of emergencies and mitigate damage to your body.

Take frequent rest breaks. This can help your body cool down and minimize the harm to your muscles. If you’re at an outdoor festival, seek shade or an air-conditioned tent. If you’re in a hot nightclub, go outside for a breather. DanceSafe has lobbied promoters to put 5 or 10-minute breaks between DJs, rather than running them back-to-back for hours on end, Gomez said.

Stay hydrated and eat properly. Giving your body enough fluids is important as you sweat to cool off. But don’t drink too much at once or you’ll risk getting water intoxication, a rare but potentially fatal condition when the excess water overwhelms the body’s ability to maintain its electrolytic balance. Don’t forget to eat. Like other stimulants, MDMA can suppress appetite, masking your body’s need for nutrition to sustain itself, Rogowski said.

Stick with a trusted friend. Make a pact with a friend that if one of you passes out, the other will stay with them. “If you are with a friend who passes out, don’t leave them alone,” Danovitch said. “They could be victimized if you leave them alone. They also could need immediate medical attention, especially if you can’t wake them up.”

Know the warning signs. Feeling hot but not sweating is a sign that your body is unable to cool itself down. Headaches, confusion, difficulty breathing, nausea, racing heartbeat and delirium are also warning signs. If you or your friends experience these symptoms, head to a medical tent or get medical attention fast. “It’s amazing the difference 10 minutes can make when it comes to a medical response,” Gomez said.