Amid all the noise about the future of its trade relationship with the U.S., Mexico is quietly creating jobs at a record pace and reducing the informality that for decades has held back its economy.

More than 517,000 Mexican workers gained access to social security in the first half of 2017, a 17 percent increase from a year ago and the most in at least two decades, according to the nation’s social security institute. While many had some kind of income before, paying into the system gives them basic benefits such as health insurance and retirement payments. Official data showed the percentage of workers in the informal economy has fallen to 57.2 percent, down from a peak of 60 percent during the 2009 global crisis.

“This is a very strong year for job creation,” said Rafael de la Fuente, chief Latin America economist at UBS. “The shining light in the whole consumption story is employment. There’s no question that you’ve made a dent in informality under this administration.”

A portion of the gains can be attributed to an overhaul of labor laws approved in 2012 under then-President Felipe Calderon, with the blessing of the Institutional Revolutionary Party of President Enrique Pena Nieto, who had just been elected. The changes allowed for more flexible contracts.

With more disposable income, workers are boosting retail spending and supporting growth at a time when the economy faces challenges from lower oil production to uncertainty about foreign investment and the future of the North American Free Trade Agreement, or NAFTA.

Mexico, the U.S. and Canada are set to start talks as soon as next month to renegotiate NAFTA, which President Trump says is responsible for millions of job losses in the U.S. and a $63 billion trade deficit with Mexico.

“The reforms, above all the labor reform, have had an impact on the formalization of jobs,” said Ernesto Mauleon Uribe, director of administration and finances in Mexico for workforce solutions company Manpower Group. “The labor reform is allowing for new types of work agreements between companies and employees, and it’s wrested some of the control from the unions, who aren’t affecting decisions as much as they used to.”

The Mexican government has said the labor overhaul, along with changes to increase competition and open the oil industry to foreign investment, would benefit workers, boost productivity and reduce inefficiencies in Latin America’s second-largest economy. While falling oil prices have hindered investment in the sector, the numbers suggest the labor reform is finally having a positive impact on employment.

Baja California Sur and Quintana Roo, states that revolve around tourism, recorded the biggest job gains in June, each increasing more than 10 percent from a year earlier. The only states to see significant employment losses were Tabasco and Campeche, oil-oriented areas that have been hurt by the drop in global prices and in Mexican output.

“The good employment numbers are a clear example of the growth in the economy and that Mexico is advancing,” Pena Nieto said when announcing the latest job creation figures in a video posted on Twitter on July 11.

The increase in workers registered with social security is also a result of changes at the nation’s tax authority that improved payroll records in industries such as construction and are requiring companies to be more diligent about enrolling their employees for benefits, said Manuel Molano, deputy director of the Mexican Competitiveness Institute.