In 363 the Persians took the region east of the Euphrates, and in the fifth century incursions by the Huns and Isaurians caused havoc. Under the emperors Anastasius and Justinian walls were constructed around many towns in the region and existing walls repaired. Caesarea was completely rebuilt and the fortified cities of Mokissos and Kamuliani were founded, so creating a formidable defense system.
The Byzantine emperors and the local inhabitants decided to take measures against sudden attacks and thus devised a system of defense comprised of several elements: governing by "themes" an "optic warning system”, the construction of additional forts, a good network of military and trade roads, and underground cities.
The system of governing by "themes" provided for the distribution of land to generals, who were directly responsible to the emperor for protecting each "theme," one of which was Cappadocia. The land remained under the control of a general who could act independently with regard to recruiting, commanding, and choosing appropriate defensive strategy. The "optic warning system" was established by placing fires and lanterns on the tops of designated hills and mountains in the provinces. This system relayed messages all the way to the Great Lighthouse in Constantinople so that the capital would be informed about the exact moment of the enemy's attack. Many forts, castles, and watchtowers were placed at strategic positions such as passes and sources of water, and also linked the main towns. In addition to these defensive measures, the local inhabitants carved underground cities for their protection.