The capital of Mataram moved several times afterwards only to return later to a location near Kotagede. From Kerta it was relocated to Plered by Agung's son Mangkurat I. Only one generation settled in Plered before the fall of this city after being defeated by some contenders of Mangkurat I in 1677. After the rebellion had been put down, his successor Mangkurat II, decided to establish a new capital named Kartasura 50 km to the east. Chinese massacre in Batavia turned into turmoil in many major parts of Java during the first half of the 18th century. The rebel leader, Sunan Kuning, occupied the throne of Mataram in Kartasura after Pakubawana II had left the capital in defeat. Pakubuwana II later regained his kingdom, but the throne had been tarnished, and so a new palace had to be established to have a purified center. In 1745 he created a new place which became the heart of the city of Surakarta.