Purchase, and multilaterally with Canada, the North American Free Trade Agreement (NAFTA). Mexico and the United States are members of various international organizations, such as the Organization of American States and the United Nations. Boundary disputes and allocation of boundary waters have been administered since 1889 by the International Boundary and Water Commission, which also maintains international dams and wastewater sanitation facilities. Once viewed as a model of international cooperation, in recent decades the IBWC has been heavily criticized as an institutional anachronism, by-passed by modern social, environmental and political issues. Illegal immigration, arms sales, and drug smuggling continue to be contending issues in 21st-century U.S.-Mexico relations. Early history U.S.–Mexico relations grew out of the earlier relations between the fledgling nation of the United States and the Spanish Empire and its viceroyalty of New Spain. Modern Mexico formed the core area of the Viceroyalty of New Spain at the time the United States gained its independence in the American Revolutionary War (1775–1783). Spain had served as an ally to the American colonists in that war. The aspect of Spanish-American relations that would bear most prominently on later relations between the U.S. and Mexico was the ownership of Texas. In the early 19th century the United States claimed that Texas was part of the territory of Louisiana, and therefore had been rightfully acquired by the United States as part of the Louisiana Purchase from France in 1803. The Spanish, however, claimed it was not, as the western boundaries of Louisiana were not clearly defined. In 1819 the dispute was resolved with the signing of the Adams–Onís Treaty, in which the United States relinquished its claims to Texas and instead purchased Spanish Florida. In 1821 New Spain gained its independence from Spain and established the First Mexican Empire under the rule of Agustín de Iturbide, who had initially fought in the royal army against the insurgents in the independence from Spain. Independent Mexico was soon recognized by the United States. The two countries quickly established diplomatic relations, with Joel Poinsett as the first envoy. In 1828 Mexico and the United States confirmed the boundaries established by the Adams–Onís Treaty by concluding the Treaty of Limits, but certain elements in the United States were greatly displeased with the treaty, as it relinquished rights to Texas. Poinsett, a supporter of the Monroe Doctrine, was convinced that republicanism was the only acceptable form of government