After their departure, Stirling's role as a royal residence declined, and it became principally a military centre. It was used as a prison for persons of rank during the 17th century, and saw few visits by the monarch. The architect James Murray restored roofs and facilities of the castle for the return of James VI & I to Scotland, who stayed in Stirling during July 1617. From 1625, extensive preparations were made for the anticipated visit of the new king, Charles I, including works to the gardens and painting of the Chapel Royal. Charles did not come to Scotland until 1633, and only stayed in the castle briefly.