In 1717, under Sultan Ahmed III (r. 1703–1730), the crumbling plaster of the interior was renovated, contributing indirectly to the preservation of many mosaics, which otherwise would have been destroyed by mosque workers.[1] In fact, it was usual for them to sell the mosaic's tesserae—believed to be talismans—to the visitors.[100] Sultan Mahmud I ordered the restoration of the building in 1739 and added a medrese (a Koranic school, subsequently the library of the museum), an imaret (soup kitchen for distribution to the poor) and a library, and in 1740 a Şadirvan (fountain for ritual ablutions), thus transforming it into a külliye, i.e. a social complex. At the same time, a new sultan's lodge and a new mihrab were built inside.