Orthodox churches and small communities of proto-Russian merchants and craftsmen remained in Livonian towns as did close trade links with the Novgorod Republic and the Pskov and Polotsk principalities. In 1481, Ivan III of Russia laid siege to the castle of Fellin (Viljandi) and briefly captured several towns in eastern Livonia in response to a previous attack on Pskov. Between 1558 and 1582, Ivan IV of Russia captured much of mainland Livonia in the midst of the Livonian War but eventually the Russians were driven out by Lithuanian-Polish and Swedish armies. Tsar Alexis I of Russia once again captured towns in eastern Livonia, including Dorpat (Tartu) and Nyslott (Vasknarva) between 1656 and 1661, but had to yield his conquests to Sweden.