In the mid-15th century, during the Thirteen Years' War, King Casimir IV of Poland often stayed in Bydgoszcz. At that time, the defensive walls were built and the Gothic parish church (the present-day Bydgoszcz Cathedral). The city was developing dynamically thanks to river trade. Bydgoszcz pottery and beer were popular throughout Poland. In the 15th and 16th centuries, Bydgoszcz was a significant location for wheat trading, one of the largest in Poland. The first mention of a school in Bydgoszcz is from 1466. In 1480, a Bernardine monastery was established in Bydgoszcz. The Bernardines erected a new Gothic church and founded a library, part of which has survived to this day. A Sejm of the Kingdom of Poland was held in Bydgoszcz in 1520. In 1522, after a decision taken by the Polish king, a salt depot was established in Bydgoszcz, the second in the region after Toruń. In 1594, Stanisław Cikowski founded a private mint, which in the early 17th century was transformed into a royal mint, one of the leading mints in Poland. In 1621, on the occasion of the Polish victory over the Ottoman Empire at Chocim, one of the most valuable and largest coins in the history of Europe was minted in Bydgoszcz – 100 ducats of Sigismund III Vasa. In 1617 the Jesuits came to the city, and subsequently established a Jesuit college. During the year 1629, shortly before the end of the Polish-Swedish War of 1626–29, the town was conquered by Swedish troops led by king Gustav II Adolph of Sweden personally. During this war, the town suffered destruction. The town was conquered a second and third time by Sweden in 1656 and 1657 during the Second Northern War. On the latter occasion, the castle was destroyed completely and has since remained a ruin. After the war only 94 houses were inhabited, 103 stood empty and 35 had burned down. The suburbs had also been considerably damaged. The Treaty of Bromberg, agreed in 1657 by King John II Casimir Vasa of Poland and Elector Frederick William II of Brandenburg-Prussia, created a military alliance between Poland and Prussia while marking the withdrawal of Prussia from its alliance with Sweden. After the Convocation Sejm of 1764, Bydgoszcz became one of three seats of the Crown Tribunal for the Greater Poland Province of the Polish Crown alongside Poznań and Piotrków Trybunalski. In 1766 royal cartographer Franciszek Florian