AHC: Spanish Viceroyalties don't break apart

How could the Spanish viceroyalties avoid breaking up and forming smaller countries after independence? They may lose some territory but overall the new country should be a modern version of the original viceroyalty.

Mexico never loses it's southern territories, Gran Colombia remains intact, and Argentina retains Uruguay, Paraguay and Bolivia, as well as its western coast.
Peru and Chile don't need any changes. The Caribbean can also go it's own way with smaller nations.

I think Mexico just needs to be more politically stable early on, same for Argentina, but both have a bigger neighbor trying to mess things up, USA and Brazil. Gran Colombia is probably the most difficult one to keep together.

MG-Viceroyalties_in_Latin_America_in_1780.jpg
 
The main problem is the natives.
Nobody remember but the Libertadores were Criollos who acted like similar USA, stealing lands to natives who before were protected by Law of Burgos and Royal Decrees. Peru, for exemple don't was Liberated, was conquered between San Martín and Simon Bolivar who compared the Peruans: Europeans, Criollos and natives, like the worse and most miserably people of the earth.
images
 
Top