Given its strategic importance, numerous enlargements to the castle were carried out immediately after the reconquest and throughout the Middle Ages. In 1323 a second reinforcement of the walls was made and the West Tower was built, this being needed as a lookout to identify Barbary pirates. In 1384 the castle served as a refuge for John of Avis and his troops during the war with Castile (1383-85).