political unrest, famines, disasters, and diseases, and was led to a nearly collapse in the late 1300s. Hồ Quý Ly as the minister had tried to fix the troubles by eliminating the Trần aristocrats, limiting monks, and promote Chinese classic learning, however, resulted in political catastrophe. Early modern period From Lê Thánh Tông's 1463 reforms onward, the Vietnamese state's structure was modeled after the Ming dynasty of China. He established six Ministries and six Courts. The government had been centralized. By 1471, Đại Việt was divided into 12 provinces and one capital city (Thăng Long), each governed by a provincial government consisted of military commanders, civil administrators, and judicial officers. Lê Thánh Tông employed 5,300 officials into the bureaucracy. A new legal code called the Lê Code was published in 1462 and was practiced until 1803. As a Confucian king, Le Thanh Tong generally disliked cosmopolitanism and foreign trade. He banned slavery, which had been popular during previous centuries, limited trade and commercial. During his reign, power was based on institutional obligations that enforced loyalty to court and merits, rather a religious relationship between aristocracy and the royal court. Self-sufficient agriculture and state-monopolized crafting were encouraged. The social hierarchy of 15th century Đại Việt comprised: Vua/Hoàng Đế–Emperor Hoàng Tử–Crown Prince Vương–Ordinary princes Công–Duke Hầu–Marquis Bá–Count Non-royal nobility: Tử–Viscount Nam–Baron After the death of Le Thanh Tong in 1497, the social-political orders he had built gradually fell apart as Đại Việt was entering its chaotic disintegration period under the reigns of his weak successors. Social upheavals, ecological crisis, corruption, irreparable failing system, political rivalry, rebellions pushed the kingdom to a climatic burst of civil war between rival clans. The last Le king was overthrown by general Mạc Đăng Dung in 1527, who promised to restore "Le Thanh Tong's golden era and stability." For the next six decades, from 1533 to 1592, the raging civil war between the Le loyalists and the Mạc had ruined much of the polity. The Trịnh and Nguyễn clans both assisted the Le loyalists in their struggle against the Mạc. After the Le-Mac war ended in 1592 with the Mạc ousted from the Red River Delta, the two clans of Trịnh and Nguyễn who revived the Le dynasty emerged as the strongest powers, and resumed their own infighting, from 1627 to 1672. The northern Trịnh clan had installed themselves as regency for the Le dynasty by 1545,