of Munkács (today Mukacheve, in Ukraine), Sárospatak and Regéc until 1680, when Ferenc's paternal grandmother, Sofia Báthory, died. Then, they moved permanently into the castle of Munkács. Rákóczi retained strong affection for this place throughout his life. Aside from his mother, Rákóczi's key educators were György Kőrössy, castellan to the family, and János Badinyi. End of the Thököly uprising Zrínyi's second husband, Imre Thököly, took little interest in Rákóczi's education, as he was by then heavily involved in politics. However, the failure of the Turks to capture the Habsburg capital in the Battle of Vienna in 1683 frustrated Thököly's plans to become King of Upper Hungary. When the Turks began to grow suspicious of his intentions, Thököly proposed sending the young Rákóczi to Constantinople as a guarantee of his goodwill. But Rákóczi's mother opposed this plan, not wishing to be separated from her son. In 1686 Antonio Caraffa besieged their residence, the castle of Munkács. Zrínyi successfully led the defence of the castle for three years, but capitulated in 1688. The two Rákóczi children fell again under the guardianship of Leopold I, and moved to Vienna with their mother. They regained their possessions, but could not leave the city without the Emperor's permission. At the age of 17, the Emperor emancipated Rákóczi from his mother, thereby allowing him to own property. His sister Julianna had interceded for him after marrying a powerful Austrian, General Aspremont. Rákóczi lived with the Aspremonts until his marriage in September 1694, to 15-year-old Princess Charlotte Amalie of Hesse-Wanfried, daughter of Charles, Landgrave of Hesse-Wanfried and a descendant of Saint Elizabeth of Hungary. The couple moved to the Rákóczi castle at Sárospatak, where Rákóczi began to manage his properties. The Treaty of Karlowitz on 26 January 1699, forced Thököly and Zrínyi into exile. Rákóczi remained in Vienna under the Emperor's supervision. Relying on the prevalent anti-Habsburg sentiment, remnants of Thököly's peasant army started a new uprising in the Hegyalja region of Northeastern present-day Hungary, which was part of the property of the Rákóczi family. They captured the castles of Tokaj, Sárospatak and Sátoraljaújhely, and asked Rákóczi to become their leader, but he was not eager to head what appeared to be a minor peasant rebellion. He quickly returned to Vienna, where he tried his best to clear his name. Rákóczi then befriended Count Miklós Bercsényi, whose property at Ungvár (today Ужгород (Uzhhorod), in Ukraine), lay next