Two new studies shed light on evolutionary changes that occurred in human DNA thousands of years ago.

Two new studies in Proceedings of the National Academy of Sciences are shaking up commonly held views about where we come from, while also pointing us down the path to future medical research.

The first, by scientists in the U.S. and Germany, charts a new model for the early spread of western Eurasian people into southern Africa. This means that genetic mixing occurred long before the period of European colonialism.

And from a collaboration by researchers in Europe and Asia comes a study based on the theory of convergent evolution in European and Roma populations, showing how certain versions of immune system genes allowed some people to survive Europe’s deadly Black Death.

Read More: Parasites in Crusaders’ Poop Offer Insight Into Medieval Famine »

In the first study, researchers found evidence of at least two genetic mixing events that influenced the DNA of Khoisans, hunter-gatherer tribes in southern Africa. Snippets of the Khoisans’ DNA most closely resembled the DNA of southern Europeans, who came in contact with them about 900 to 1,800 years ago. That’s far earlier than scientists thought Europeans made contact with southern Africans.

Khoisans weren’t the only ones affected by genetic mixing. The researchers note that the genomes of Kenyan, Tanzanian, and Ethiopian populations also show evidence of mixing events involving western Europeans, which occurred about 2,700 to 3,300 years ago.

On the flip side, the second study deals with what happens when populations move away from one another, and the evolutionary advantages they sometimes gain.

The researchers stumbled on an unusual discovery in the Roma, sometimes called gypsies, who migrated from northern India to Europe about 1,000 years ago. The Roma and European Romanians, who the Roma lived alongside but generally did not marry, were both exposed to the Black Death, which wiped out million of Europeans in the 14th century.

Researchers looked for similarities in the DNA of Roma people and European Romanians that were also different from markers in the DNA of northern Indians, who did not face the Black Death.

A cluster of genes found in Roma and Romanians code for toll-like receptors, proteins that are critical for defending the immune system. The genes were not found in north Indians, so natural selection must have favored them in order for them to have survived in Europe after the Black Death.

Today, these findings could offer insight into why European people have higher rates of autoimmune diseases than people in other countries. Perhaps their immune systems are on high alert from past experience with the plague.

Learn About Causes of Rheumatoid Arthritis »

Both studies are exciting for their potential to explain medical mysteries. According to the scientists responsible for the African migration study, the research fills in the gaps left by a lack of written history. Most of our knowledge comes from archaeology and linguistics—uncovering genetic data is trickier.

“The hunter-gatherer and pastoralist populations of southern Africa are among the culturally, linguistically, and genetically most diverse human populations. However, little is known about their history,” the researchers wrote.

See 6 Surprising Facts About the Microbes Living in Your Gut »