A castellan, or constable, was the governor of a castle in medieval Europe. Its surrounding territory was referred to as the castellany. The word stems from castellanus. A castellan was almost always male, but could occasionally be female, as when, in 1194, Beatrice of Bourbourg inherited her father's castellany of Bourbourg upon the death of her brother, Roger. Similarly, Agnes became the castellan of Harlech Castle upon the death of her husband John de Bonvillars in 1287. The title of "governor" is retained in the English prison system, as a remnant of the medieval idea of the castellan as head of the local prison. After the fall of the Western Roman Empire, foreign tribes migrated into western Europe, causing strife. The answer to recurrent invasion was to create fortified areas which evolved into castles. Some military leaders gained control of several areas, each with a castle. The problem lay in exerting control and authority in each area when a leader could only be in one place at a time. To overcome this, they appointed castellans as their trusted vassals to manage a castle in exchange for obligations to the landlord, often a noble. In the 9th century, as fortifications improved and kings had difficulty making their subordinates pay their taxes or send the military aid they demanded, castellans grew in power, holding their fiefdoms without much concern for their overlord's demands. This changed as kings grew in power and as the Holy Roman Emperors replaced recalcitrant vassals with rival ministerial appointments. Majordomo and Medieval warfare Usually the duties of a castellan consisted of military responsibility for the castle's garrison, maintaining defences and protecting the castle's lands, combined with the legal administration of local lands and workers including the castle's domestic staff. The responsibility applied even where there was no resident castellan at the castle, or if he was frequently absent. A castellan could exercise the power of the "ban" – that is, to hear court cases and collect fines, taxes from residents, and muster local men for the defence of the area or the realm.