Although few buildings remain from this period there are records of works in 1617, 1618, and 1628-9. A replacement Wallace Tower was built superseding the medieval building. In June 1618 masons were working on the upper storey and it was decided to make the tower larger. Externally it was finished with lime plaster called harling. At the south side there was a bell house. By 1627 it was discovered that the keeper Sir John Stewart of Methven had neglected the fortress. He was replaced by Sir John Stewart of Traquair who recorded the poor state of the building. Surviving accounts mostly record work on the artillery and the 'foir yet wall' a defence on the southern side. The Scottish Parliament in 1644 judged that the castle was likely to more hurtful than useful to the country. In November 1645 the Committee of Estates approved the recruitment of thirty extra soldiers by the keeper John Semple to guard the increased number of prisoners. The castle's strategic importance declined after Oliver Cromwell's death in 1658. However, due to threats posed by Jacobites and the French in the eighteenth century, new structures and defences were built and the castle was garrisoned until World War II. Some documentation for these later works is preserved in the National Archives of Scotland.. How many periods of works are in the records for the medieval building?