Stafford was already an important place when King Alfred's daughter fortified the town against the Danes; she made it both a royal borough and a market town. William the Conqueror destroyed much of the town to build a castle after the defeat of Edric the Wild. The town then flourished with a magnificent new church and a royal charter. By Tudor times the population suffered a sharp decline, but then a few wealthy families revived its trade. In the 18th century shoe manufacturing became the dominant industry and the railways attracted heavy engineering.