During the 5th century, the last de jure Western Roman Emperor Julius Nepos ruled his small realm from the palace after fleeing Italy in 475. The period ends with Avar and Croat invasions in the first half of the 7th century and the destruction of almost all Roman towns. Roman survivors retreated to more favourable sites on the coast, islands, and mountains. The city of Dubrovnik was founded by such survivors from Epidaurum.