After a mere six months on the job, White House chief of staff Reince Priebus is headed out the door.

President Donald Trump tweeted Friday afternoon that he’d appoint retired Gen. John Kelly, currently serving as secretary of Homeland Security, to replace Priebus in the position.

It’s the highest-profile personnel switch yet in what’s been an unusually tumultuous administration so far — and clearly an acknowledgment by the president that his team needs serious changes. It also comes the afternoon after the Republican health bill went down to defeat in the Senate (though Priebus is now telling reporters he resigned Thursday).

By pushing out Priebus, Trump is ousting a Republican Party man and replacing him with a less political former general who has few ties to the GOP or even politics in general. This newfound preference for outsiders is in keeping with Trump’s recent appointment of Anthony Scaramucci as communications director — an event that seems to have precipitated Priebus’s exit.

Still, while Priebus is nominally the top-ranking White House staffer and is widely viewed as weak and ineffective, it’s unclear how much blame he truly deserves for the administration’s biggest missteps (beyond the health reform debacle, which he does seem to have played a leading role in).

Because of the way Trump has chosen to run his team, Priebus hardly even got the chance to operate as an effective chief of staff. Instead, he was constantly hemmed in by other advisers like Steve Bannon — named to a “chief strategist” position that wasn’t subordinate to Priebus — and Jared Kushner, who, as Trump’s son-in-law, seemingly can’t be fired.

All the while, he was undercut by the president himself at every turn — in private, it’s reportedly common for Trump to mock and belittle Priebus. The president simply never really respected his chief of staff, and that situation just wasn’t tenable.

Priebus was picked to represent the GOP. But he was an odd pick for chief of staff from the start.

Trump’s announcement that he’d chosen RNC Chair Priebus as chief of staff back during the transition was initially greeted by sighs of relief in Washington.

Though Priebus was a blank slate on policy, he was close to the Republican Party establishment and therefore seemed to be the more moderate choice compared to the other main contender, outsider bomb-thrower Steve Bannon.

But Priebus had two big things working against him from the very start.

First, though Trump of course knew Priebus due to their shared efforts to elect Republicans in 2016, the two did not have a particularly close, warm, or friendly relationship.

That’s an enormous problem for a chief of staff. Former President Gerald Ford once said that the ideal pick for the job should be “a person that you have total confidence in, who works so closely with you that in effect he is almost an alter ego.”

But Priebus and Trump have nothing in common. Unlike other advisers who Trump seems to genuinely like, Priebus isn’t a rich businessman, an outsider populist, a member of Trump’s family, or someone who endorsed Trump early.

Instead, Priebus is a Republican Party man. And Trump picked him specifically for that reason — because the Trump team thought he knew the ways of Washington and would be able to work effectively with the GOP’s congressional leaders, particularly his fellow Wisconsinite Paul Ryan.

Yet that leads us to our second problem: Priebus had very little experience actually working in government.

Though Priebus may have been the GOP establishment-associated figure who Trump happened to have interacted with the most, the fact is that Priebus’s political experience has entailed running the Wisconsin GOP and then the national Republican Party to help them win elections. He’s never held elected office or even worked for an elected official. (He was a clerk for a Wisconsin state assembly committee and a law clerk, but that appears to be it.)

A job that entails fundraising and strategizing for a political party is very different from a job that entails managing the vast federal bureaucracy to enact policy, or working with Congress to get bills passed. And Priebus’s résumé was obviously very weak in those latter areas, which heralded trouble ahead.

Then Trump didn’t actually let Priebus be a real chief of staff

So Priebus ended up being given the “buck stops here” job of chief of staff, but lacked the stature or experience to actually perform well in it.

And things got worse from there.

There are several important factors to becoming a strong chief of staff. It’s important to control or at least heavily shape who gets access to the president and how he spends his time. It’s important to structure a decision-making or policymaking process. It’s important that the chief be at the top of a clear chain of command. And it’s important that, throughout the federal government, the chief is viewed as speaking for the president.

Priebus did none of these things — or rather, the president didn’t let him do any of them.

Much like how Trump ran his campaign, he preferred to have free-form, unstructured interactions with his many staffers and outside advisers. The policymaking process was chaotic, and could be upended by a presidential tweet at any time. Far from being at the top of the White House pyramid, Priebus was listed behind chief strategist Steve Bannon in the press release announcing their appointments, and soon Trump gave his son-in-law Jared Kushner a top White house job too — empowering someone who could circumvent the chief any time he liked.

And rather than turning Priebus into an “alter ego” who could be seen as carrying out his wishes and speaking with his voice, Trump made it clear that he didn’t even really respect Priebus very much.

Tales of the president mocking, needling, and complaining about his chief of staff to others have circulated far and wide. Trump reportedly coined a mocking nickname for him (“Reince-y”), and repeatedly brought up the fact that Priebus advised him to quit the race last October, after the Access Hollywood tape leaked. And if the president is known not to respect the chief of staff, you can be sure that the rest of the executive branch won’t respect him either.

Beyond his troubles with Trump, Priebus feuded with other top White House advisers. At first, he seemed to be at odds with Bannon; then, the two seem to have realized that Kushner and other advisers lacking ties to the Republican Party or conservative movement were a far greater threat to both their influence. And many of the longtime Trump loyalists in the administration never particularly warmed to Priebus either.

Priebus’s biggest impact may have been latching Trump to Paul Ryan’s health care effort

Beyond the general chaos and bad management, Priebus’s biggest influence on the administration may lie in the fact that Paul Ryan’s Obamacare repeal effort became President Donald Trump’s top legislative priority and ate up much of his first year in office — and stalled dramatically early Friday morning.

It wasn’t a given that President Trump’s first-year legislative agenda would be dominated by health care, an issue he’s never seemed particularly passionate about. Indeed, he sometimes didn’t even seem to agree with Republican leaders on the issue — while he did constantly criticize Obamacare as a failure, he also argued against Medicare and Medicaid cuts during the campaign and, during the transition, promised his plan would provide “insurance for everybody.”

But when Paul Ryan and Mitch McConnell plotted out their legislative strategy for 2017, they made the call that Obamacare repeal would be their first and highest priority — in part due to misjudging how easy it would be.

Trump didn’t have to go along with this. He could have tried to set his own legislative agenda — either by demanding Congress tackle a big infrastructure bill, starting with tax reform, or even crafting his own health care bill.

Instead, Trump decided to follow Ryan’s lead. And Ryan’s ally Reince Priebus appears to be a big reason why. According to the New York Times’ reporting, Trump made the decision to put health care first “almost in passing” in meetings with Ryan, Priebus, and Vice President Mike Pence.

Indeed, some public statements from Trump have made it seem like he was told that he had to put health care first for complex congressional leaders — which is not in fact true. (Republican leaders thought they could pass bigger tax cuts overall if they passed health reform first, but they certainly didn’t have to do it first.)

“I can’t do it [tax reform] until we do health care,” Trump said in February. “Statutorily, that’s the way it is.” He added: “I would like to do the tax first.”

Over the next few months, Trump proceeded to yoke himself to Republican leaders’ increasingly unpopular effort, staking his prestige on its success. He opted not to release a plan that would ensure everyone. He chose Ryan’s close ally Rep. Tom Price as his Health and Human Services Secretary. He championed the House and then the Senate bills despite their unpopularity and deviations from his campaign promises. Indeed, the frenzied effort to revive the House bill in late April and early May was said to be motivated partially by Priebus’s fears that his job would be at risk if he didn’t deliver.

All of this, so far, has been to no avail. And a more effective chief of staff would have made clear that following Congress’s lead on health reform wasn’t Trump’s only option — or at least would have made sure the president understood that he had alternatives. But whether due to a desire to help out Paul Ryan or due to simple incompetence, Priebus evidently failed to do so.

Scaramucci’s arrival meant the beginning of the end for Priebus

Rumors of Priebus’s imminent demise started early in the administration and, until he was replaced Friday evening, continued to appear in the press regularly. More recently, rumors circulated that other Trump family members, like Ivanka Trump and first lady Melania Trump, wanted Priebus out too.

But the event that triggered the chain reaction resulting in his downfall was Trump’s decision to hire Anthony Scaramucci, a Trump fundraiser from the finance industry, as White House communications director on July 21.

There had long been bad blood between Priebus and Scaramucci. As Vicky Ward reports in a dishy Huffington Post piece, Priebus blocked Scaramucci from getting an administration job back in January. He pulled this off by telling Trump that Scaramucci’s sale of his “fund of funds” SkyBridge Capital to a Chinese firm seemed rather shady, per Ward.

But Scaramucci persisted, looking a way into the administration. And the president had long been unhappy with the performance of his press shop, with his first communications director Mike Dubke leaving after just three months. So Trump decided to try something different, and handed Dubke’s job to Scaramucci, an outsider with zero communications experience beyond his own appearances on television.

Spicer threatened to quit if Scaramucci was brought on, and made good on his promise. A few days later, Scaramucci publicly accused Priebus of leaking information to hurt him (the specific accusation was false), and told reporter Ryan Lizza that Priebus was “a fucking paranoid schizophrenic, a paranoiac.” Other advisers have also reportedly sought to convince Trump that Priebus is a “leaker.”

And now, Trump has made the call — Priebus is out. The decision likely reflects some understandable discontent with how Trump’s reliance on Republican Party establishment figures has turned out so far, given the fate of the health bill.

For all we know, Kelly might do well in the role. But in the short term, given how things have gone for this administration so far, expect some chaos.