In 1550s, a wooden palisade surrounding the cloister was replaced with 1.5 km-long stone walls, featuring twelve towers, which helped the monastery to withstand a celebrated 16-month Polish-Lithuanian siege in 1608-1610. A shell-hole in the cathedral gates is preserved as a reminder of Wladyslaw IV's abortive siege in 1618. By the end of the 17th century, when young Peter I twice found refuge within the monastery from his enemies, numerous buildings had been added. These include a small baroque palace of the patriarchs, noted for its luxurious interiors, and a royal palace, with its facades painted in checkerboard design. The refectory of St. Sergius, covering 510 square meters and also painted in dazzling checkerboard design, used to be the largest hall in Russia. The five-domed Church of John the Baptist's Nativity  was commissioned by the Stroganovs and built over one of the gates. Other 17th-century structures include the monks' cells, a hospital topped with a tented church, and a chapel built over a holy well discovered in 1644.. What helped the monastery to withstand a siege?