Tagalog civilization has been a distinctive configuration for at least one thousand years, subject to the various cultural influences operative in mainland and insular Southeast Asia since the Neolithic period. Long before the Spanish began colonization in the last half of the sixteenth century, Tagalog society on Luzon was organized in loose "confederations" of local groupings sometimes called "kingdoms." In general, Tagalogs had a system of writing (a syllabary derived from Sanskrit), an advanced technology including metallurgy, a complicated social system with hierarchical classes (including a category of individuals termed "slaves" by early Spanish sources), and religious patterns that varied regionally. The Indonesian empires of Sri Vijaya and Majapahit left their imprint on language, religion, and technology—through both trade and settlement. The Chinese for centuries used ports along the western coast of Luzon as stopping points in their trade with the Spice Islands to the south and local trading centers. Islamic sultanates had been established around Manila Bay not long before the Spanish began almost 350 years of occupation in the middle of the sixteenth century. During the seventeenth and eighteenth centuries Manila was one of the major seaports of the world as the transshipment point in the famous Manila galleon trade that exchanged silver from Mexico for silks and other luxury wares of China. By the middle of the nineteenth century, strong resistance to Spanish rule had developed in the Philippines, especially in the Tagalog area, which produced the national heroes José Rizal, Andres Bonifacio, and Emiliano Aguinaldo. Before Americans came to the Philippines during the Spanish-American War in 1898 there was a full-scale insurrection in process, which continued against the American occupation until 1902. The first Republic of the Philippines was established during this time at the Barasoin Church in Malolos, Bulacan, 48 kilometers northwest of Manila, in the midst of what is considered the land of the deepest ( malalim ) and purest dialect of Tagalog. American colonial control officially lasted almost fifty years. During World War II, the battles of Bataan and Corregidor, as well as the Death March, occurred in the Tagalog area. Independence was granted in 1946 after a three-year occupation by the Japanese. Until 1952 the insurgent Hukbalahap army waged some of its most intensive battles against the new Republic of the Philippines in the Tagalog provinces. Recently the American presence and influence have lessened, with Japan, Australia, New Zealand, and European countries becoming important economically and technologically. In the early Spanish period most of the people of the Philippines were called "Moros" and later "Indios." The term "Filipino" then referred to persons of Spanish descent born there.