The 1805 Battle of Trafalgar had all but shattered the Spanish navy, with the Peninsular War leaving Spanish society overwhelmed by continuous warfare and badly damaged by looting. While the Spanish Empire collapsed, the maritime trade in the Americas and Philippines fell to a trickle, and Spain's military struggled to keep their colonies, with Mexico getting its independence in 1821. The overseas revenue was at a historic low, the royal coffers were empty. Balancing the books and recruitment to the military became an overriding concern for the Spanish Crown, with the governments under King Ferdinand VII failing to provide new solutions or stability.