he was imprisoned by Stephen I. The Dowager Queen remained in Germany as a nun until her death, in 1063. Taking advantage of the chaos and his neighbour's weakness, Duke Bretislaus I of Bohemia invaded and ravaged the country in 1039. Lesser and Greater Poland were severely pillaged, Poznań was captured, and Bretislaus sacked Gniezno, taking the relics of Saint Adalbert, Radim Gaudentius, and the five hermit brothers with him. On the way back he conquered part of Silesia, including Wrocław, destroyed religious buildings which were built by Mieszko I during the feast of the conversion of Poland, and plundered Mieszko I's tomb. Restoration After initially escaping to Hungary, Casimir went to Germany, where in 1039 his relative the Emperor Henry III (who feared the increased power of the Bohemian ruler) gave him military and financial support. Casimir received a force of 1,000 heavy footmen and a significant amount of gold to restore his power in Poland. Casimir also signed an alliance with Yaroslav I the Wise, the Prince of Kievan Rus', who was linked with him through Casimir's marriage with Yaroslav's sister, Maria Dobroniega. With this support, Casimir returned to Poland and managed to retake most of his domain. In 1041, Bretislaus, defeated in his second attempted invasion by Emperor Henry III, signed a treaty at Regensburg (1042) in which he renounced his claims to all Polish lands except for Silesia, which was to be incorporated into the Bohemian Kingdom. It was Casimir's success in strengthening royal power and ending internal strife that earned him the epithet of "the Restorer". The treaty gained Casimir a period of peace on the southern border and the capital of Poland was moved to Kraków, the only major Polish city relatively untouched by the wars. It is probable that the Holy Roman Emperor was pleased with the balance of power that had been restored to the region and forced Casimir not to crown himself the King of Poland. In 1046 Emperor Henry III held royal and imperial courts at Merseburg and Meissen, at which he ended the strife among the Duke of Pomerania (Dux Bomeraniorum), Duke Bretislaus of Bohemia, and Casimir I. In 1047 Casimir, aided by his Kievan brother-in-law, started a war against Masovia and seized the land. It is probable that he also defeated Miecław's allies from Pomerania and attached Gdańsk to Poland. This secured his power in central Poland. Three years later, against the will of the Emperor, Casimir seized Bohemian-controlled Silesia, thus securing most of his father's domain. In 1054 in Quedlinburg, the Emperor ruled that Silesia was to remain in Poland in exchange for a yearly tribute of 117 kg. of silver and 7 kg. of gold. At that time Casimir focused on internal matters. To strengthen his rule he re-created the bishopric in Kraków and Wrocław and erected the new Wawel Cathedral. During Casimir's rule heraldry was introduced into Poland and, unlike his predecessors, he promoted landed gentry over the drużyna as his base of power. One of his reforms was the introduction, to Poland, of a key element of feudalism: the granting of fiefdoms to his retinue of warriors, thus gradually transforming them into medieval knights. Marriage and issue Casimir married Maria Dobroniega (ca. 1012–1087), daughter of Grand Duke Vladimir I of Kiev. There is no consensus among historians as to when it took place. Władymir D. Koroliuk said that it was in 1039, Aleksej A. Szachmatow and Iwan Linniczenko agreed on 1041, while Dymitr S. Lichaczew postulated that it occurred during 1043. Casimir and Maria had five children: Bolesław II the Bold (ca. 1043 –