The U.S. immigration process is complex and controversial, and an influx of asylum seekers this year is overwhelming the system.

As the Trump administration continues to change U.S. immigration policy, here are some of the basics of the government’s immigration system.

Before crossing into the U.S.

One method of legal immigration into the United States is for migrants to present themselves to U.S. Customs and Border Protection officials at ports of entry and request asylum. Undocumented migrants who are apprehended while trying to cross the border illegally between ports of entry also can request asylum; the Trump administration tried unsuccessfully to change this policy in November.

Metering occurs when federal immigration officials limit the number of migrants who can request asylum at international bridges and other ports of entry each day. CBP officials stop migrants before they enter U.S. territory, forcing asylum seekers to wait for weeks or months in Mexico until they are allowed to cross. Metering has occurred since at least 2016, under the Obama administration, according to the Department of Homeland Security’s Office of Inspector General.

After crossing into the U.S.

Migrants who request asylum at ports of entry (and those who are apprehended) first spend time in U.S. Border Patrol processing facilities. Border Patrol is part of Customs and Border Protection, which falls under the Department of Homeland Security.

At least seven children have died after being in federal custody since September, and conditions at Border Patrol processing centers have been blamed for causing or worsening their illnesses. Conditions at these facilities vary widely, but recent reports have described overcrowding, unsanitary conditions and a shortage of supplies at sites in McAllen, Clint and other Texas towns. A recent report from the DHS Office of Inspector General confirmed that children were denied showers, clean clothing and hot meals.

The federal government went to court in June to argue that it’s not required to provide migrant children with toothbrushes, soap, towels or showers under the 1997 Flores agreement, which mandates that such children be housed in “safe and sanitary” conditions.

The Flores agreement dictates that children should not be held in processing facilities for more than 72 hours, which is also CBP’s standard for adults. But the OIG report released in June noted that 31% of children in the five facilities it investigated early that month had been held longer than three days.

Four options after leaving the processing facility

When a person requests asylum, U.S. Citizenship and Immigration Services requires a wait of at least one day before the migrant has an interview with an asylum officer, who determines whether that person has “a credible fear of persecution or torture.” The migrant can seek legal advice or waive the wait time.

An asylum seeker who passes this interview will be referred to a judge for a full hearing on the claim. Unaccompanied minors, who also go through the asylum process, are sent to migrant children’s shelters. A DHS official determines whether adults and families will be returned to Mexico, and ICE decides whether those who stay in the U.S. will be detained or released while waiting for their hearings.

Two U.S. policies have contributed to an increase in migrants in Mexican border cities: metering and the Migrant Protection Protocols, known as “remain in Mexico.” The policy began in San Diego in January, when DHS cited a backlog of almost 800,000 cases in U.S. immigration courts.

The remain in Mexico policy, which requires migrants who have requested asylum to wait in Mexico until their U.S. court date, expanded to El Paso in March and Laredo in July. The program is also starting in the Border Patrol’s Rio Grande Valley Sector, officials said.

By mid-July, almost 20,000 people had been returned to Mexico under the program, according to that country’s National Institute of Migration. According to guidelines from Customs and Border Protection, certain groups are excluded, including unaccompanied minors, migrants who are likely to encounter persecution or torture in Mexico, and people with physical or mental health issues.

The nonprofit organization Human Rights Watch released a report in July detailing hardships and violence experienced by asylum seekers in Mexico.

Some families and single adults are transferred from Border Patrol facilities to detention centers run by Immigration and Customs Enforcement, also part of DHS. These facilities have beds, showers, cafeterias, infirmaries and access to immigration courts, but they are not licensed by states and thus are not supposed to house children for more than 20 days.

A recent report by the House Committee on Oversight and Reform found that children who had been reunited with their families — after being separated last summer under the Trump administration’s “zero tolerance” policy — spent an average of 58 days in ICE facilities in Dilley and Karnes City, about an hour’s drive southwest and southeast of San Antonio, respectively. After their detention, 80% of those families were released into the U.S. rather than deported.

As of July 10, ICE had 244 families in custody, mostly in Dilley. The U.S. government considers only a parent and child to be a legal family unit, so officials can separate children who arrive at the border with other relatives, such as siblings, aunts, uncles or grandparents.

Unaccompanied migrant children processed through Border Patrol often go to shelters run by the Office of Refugee Resettlement, part of the U.S. Department of Health and Human Services. Shelters are run by private companies that contract with the federal government but are regulated by the states, unless they are deemed temporary facilities.

ORR, which provides care and finds sponsors for unaccompanied minors, operates 168 shelters in 23 states — including 35 in Texas, plus a new facility in Carrizo Springs. Almost 50,000 children were referred to ORR in fiscal year 2018, which ended in October, and most came from Guatemala, Honduras and El Salvador, according to an HHS fact sheet.

At the beginning of June, the Trump administration canceled English classes, recreational programs and legal aid for children in these shelters, but those services were restored with additional government funding later that month. ORR facilities also provide education, mental and physical health services and case management, according to the fact sheet, which was updated in July.

At the end of May, children spent an average of 45 days in ORR care before being placed with a legal guardian or sponsor, down from an average of 93 days in November, according to the agency. As of July 8, about 12,500 unaccompanied migrant children were in federal shelters.

Under various policies, migrants who have been processed by Border Patrol can travel to sponsors in the U.S. with notices to appear in court, a process known as “catch and release.” This practice has recently strained resources in some Texas cities, even those far from the border.

San Antonio leaders transformed an old Quiznos downtown into its Migrant Resource Center, where people receive food and hygiene products before being escorted to a nearby shelter for the night.

Whether waiting in the United States or Mexico, migrants face a yearslong asylum process. And programs like MPP have made it more difficult for migrants to get assistance from immigration attorneys and other advocates.

The U.S. Justice Department recently stopped allowing attorneys and immigrant advocates in El Paso to offer “know your rights” briefings before asylum seekers’ initial court hearings, and lawyers there say “friends of the court” are no longer allowed to help judges and migrants during these hearings. In one attempt to hasten the processing of asylum cases, CBP planned to erect tents in Laredo in which judges could preside over hearings via video conferencing.

With the backlog in immigration cases, it takes months or years before a judge makes a final ruling on a migrant’s asylum claim. Those who are granted asylum can apply for a green card after one year and for citizenship five years after that. Those who are not granted asylum are deported.

In 2017, asylum was granted in 20.22% of cases and denied in 33.51%, according to PolitiFact, and the remaining cases were closed for other reasons.