Having rejected peace proposals from its enemies, Ivan the Terrible found himself in a difficult position by 1579, when Crimean Khanate devastated Muscovian territories and burnt down Moscow (see Russo-Crimean Wars), the drought and epidemics have fatally affected the economy, Oprichnina had thoroughly disrupted the government, while The Grand Principality of Lithuania had united with The Kingdom of Poland (1385–1569) and acquired an energetic leader, Stefan Batory, supported by Ottoman Empire (1576). Stefan Batory replied with a series of three offensives against Muscovy, trying to cut The Kingdom of Livonia from Muscovian territories. During his first offensive in 1579, with 22,000 men, he retook Polotsk; during the second, in 1580, with 29,000-strong army, he took Velikie Luki, and in 1581 with a 100,000-strong army he started the Siege of Pskov. Frederick II of Denmark and Norway had trouble continuing the fight against Muscovy unlike Sweden and Poland. He came to an agreement with John III in 1580 giving him the titles in Livonia. That war would last from 1577 to 1582. Muscovy recognized Polish–Lithuanian control of Ducatus Ultradunensis only in 1582. After Magnus von Lyffland died in 1583, Poland invaded his territories in The Duchy of Courland and Frederick II decided to sell his rights of inheritance. Except for the island of Œsel, Denmark was out of the Baltic by 1585. As of 1598 Inflanty Voivodeship was divided onto: