The complex of palaces was rebuilt and expanded several times during its history. Much of the complex was destroyed during the Nika riots of 532 and was rebuilt lavishly by the emperor Justinian I. Further extensions and alterations were commissioned by Justinian II and Basil I. However, it had fallen into disrepair by the time of Constantine VII, who ordered its renovation. From the early 11th century onwards the Byzantine emperors favored the Palace of Blachernae as an imperial residence, though they continued to use the Great Palace as the primary administrative and ceremonial center of the city. It declined substantially during the following century when parts of the complex were demolished or filled with rubble. During the sack of Constantinople by the Fourth Crusade, the Palace was plundered by the soldiers of Boniface of Montferrat. Although the subsequent Latin emperors continued to use the Palace complex, they lacked money for its maintenance. The last Latin emperor, Baldwin II, went as far as removing the lead roofs of the Palace and selling them.