Towering over the city, Edinburgh Castle was first inhabited in the 9th century BC, and later became an important fort for the Votadini people (Gododdin) who called it Din Eidyn. Captured by the Angles in AD 638, the name was modified to Edinburgh. The town and fortress remained in their hands until they were driven out by the Scots under King Malcolm II in 1018. Under the supervision of King David I (1124-1153) the castle began to grow into a royal fortress. During the Wars of Scottish Independence (1296-1328, 1332-1357), the castle traded hands four times, with the English capturing it in 1296 and 1335, and the Scots retaking it 1314 and 1341. In 1356, the castle began to assume some of its present appearance following an expansion of its defenses by David II. With the ascendancy of the Stewart dynasty in Scotland, the castle's role began to grow. The castle was greatly expanded during the reign of James III (1460-1488) as he undertook a massive building program to turn it into his royal residence. This was continued by his son, James IV, who completed the Great Hall in 1511.