When the fighting between Sweden and Poland had ceased the task remained for Charles XII to secure the new order against coup attempts from the Saxons and Augustus' ally tsar Peter. Throughout the time of the war Peter had been desperately trying to modernize his outdated army after the defeat at Narva, even though the Russian military was adequate to operate against poorly defended cities throughout the Swedish Baltic provinces. After Wolmar von Schlippenbach's failures in the battles of Erastfer and Hummelshof, the Russians had conquered Nöteborg and Nyenskans, as well as beginning the construction of Petersburg, which would become their first naval base in the Baltic sea. Throughout 1704 Dorpat and Narva had also been lost. However, the Russians had failed to drive the Swedes out of Courland, and thus the Swedes remained in control of the eastern Baltic sea and were able to maintain a steady supply of resources to the army in Poland. This has been credited to Adam Ludwig Lewenhaupt for his victories at Jakobstadt and Gemauerthof.