When Kevin McAleenan, the U.S. Customs and Border Protection commissioner, takes over at Homeland Security this week he will become the fourth person officially to lead the department under President Trump.

But the events of the past four days suggest a single figure is the real head, pulling strings from behind the scenes, according to officials and those close to the Trump administration.

Stephen Miller, 33, a senior policy adviser and chief speechwriter at the White House, is the driving force behind Trump’s recent focus on immigration at the southern border and the man responsible for the major overhaul underway at the Department of Homeland Security.

Private battles spilled into public on Sunday when Trump announced on Twitter that Kirstjen Nielsen was standing down.

Miller, who was an aide to Jeff Sessions when the then-senator for Alabama was a lonely voice on Capitol Hill for what would become GOP orthodoxy on immigration under Trump. With Steve Bannon, then Trump's top strategist and now persona non grata in Trumpworld, Miller co-authored Trump’s bleak "American carnage" inauguration speech.

He grew up in liberal California and was a rare right-winger at Duke University. Mocked by liberals for his dour manner, supposed "spray-on" hair, and assailed even by an elementary school teacher who said he had been, aged nine, "a strange dude" who ate glue, Miller has always been an outlier. Now, in the White House at least, Miller is in the mainstream and in a commanding position.

An increasingly influential figure in the White House since the departure of John Kelly as chief of staff, Miller pushed for the removal of Nielsen, a Kelly protege. Miller had been lobbying Nielsen and midlevel officials to do more to stem the migrant influx.

Max Boot, military affairs analyst and prominent Trump critic, posted on Twitter: “Just get it over with and nominate Stephen Miller since he’s the shadow DHS secretary anyway.” Boot is a virulent Trump critic but on this issue his analysis coincided with that of Trump allies who agree with Miller.

A former official who worked with Miller during the campaign said Nielsen had been vulnerable for months, seen as an obstruction to officials who wanted to go harder and further on the problem. “On Nielsen, it was clearly Miller who pushed this, this is exactly how he operates, but at the same time you can’t underestimate how much of a crisis this had become, and this was a culmination of all of that," he said. "Ultimately she was on borrowed time once John Kelly left.”

Immigration hardliners welcomed Nielsen’s departure. Rosemary Jenks, director of government relations at Numbers USA, said too many senior figures at agencies dealing with immigration did not share Trump’s agenda.

“It was time for Secretary Nielsen to go,” she said. “She came into the department with a reputation in cybersecurity but not immigration. Obviously right now immigration is the focus. I think she was dumped into the deep end without a life preserver and she sank.”

There is no indication that Miller was of the mind to throw her a flotation device.

Nielsen’s position has been in question almost as soon as she replaced Kelly as head of the department. She told friends she was close to resigning after the president berated her during a cabinet meeting in May last year, accusing her of not doing enough to reduce the number of illegal border crossings.

Officials close to Nielsen briefed journalists that it was the influence of Miller that ultimately cost her the job. White House officials on Monday confirmed the departure of Randolph "Tex" Alles as head of the Secret Service on Monday, just a day after Trump announced Nielsen was leaving Homeland Security.

What some view as a Miller "purge" began on Thursday when the White House suddenly pulled the nomination of Ronald Vitiello as head of Immigration and Customs Enforcement.

All were seen as allies of Kelly, who left the White House in January. Like Kelly, Alles was a Marine general. Kelly was an enlisted man who became a four-star general, while Alles was a two-star aviator and former Top Gun instructor at Miramar.

Nielsen's ouster creates an even wider void at the top of DHS. The department was already without a deputy secretary, leaving Claire Grady, the under secretary for management, to fill the role for the past year.

And the clear-out may not be over with reports that L. Francis Cissna, head of Citizenship and Immigration Services and John Mitnik, the department’s general counsel, were next in Miller’s firing line.

White House officials scoffed at the idea the shake-up constituted a “purge." They played down any connection between the departures of Nielsen and Alles. “The two things are not related,” said one, who declined to be named discussing personnel matters, other than to say that Trump remained focused on driving down the number of migrants attempting to cross the southern border.

With crossings at an 11-year high, the Trump administration has stepped up its rhetoric.

On Friday, Trump announced that the U.S. was “full” and that it was time to get rid of the entire asylum system, while condemning a federal court order mandating minimum levels of care for migrant children.

“Can't take you anymore, I'm sorry. So turn around. That's the way it is," Trump said in a message to asylum seekers during a trip to the border. Trump needs no speechwriter on border issues, but this was a message that Miller himself could have crafted.