The Royal Palace comprises the former royal apartments, which were the residence of the later Stewart monarchs. It was begun in the mid 15th century, during the reign of James IV. The building was extensively remodelled for the visit of James VI to the castle in 1617, when state apartments for the King and Queen were built.