In 1038, Kraków became the seat of the Polish government. By the end of the 10th century, the city was a leading centre of trade. Brick buildings were constructed, including the Royal Wawel Castle with St. Felix and Adaukt Rotunda, Romanesque churches such as St. Adalbert's, a cathedral, and a basilica. The city was sacked and burned during the Mongol invasion of 1241. It was rebuilt practically identical, based on new location act and incorporated in 1257 by the high duke Bolesław V the Chaste who following the example of Wrocław, introduced city rights modelled on the Magdeburg law allowing for tax benefits and new trade privileges for the citizens. In 1259, the city was again ravaged by the Mongols. A third attack in 1287 was repelled thanks in part to the new built fortifications. In 1335, King Casimir III of Poland (Kazimierz in Polish) declared the two western suburbs to be a new city named after him, Kazimierz ("Casimiria" in Latin). The defensive walls were erected around the central section of Kazimierz in 1362, and a plot was set aside for the Augustinian order next to Skałka.