In the wake of the 2016 presidential nomination process, it became fashionable to talk about the declining influence of the two major U.S. political parties on their voters. That’s for pretty good reason. The Republican nomination of Donald Trump, despite his tepid support from Republican elected officials and his frequent breaks from Republican orthodoxy, defied the scholarly consensus about how “party elites” are supposed to have sway over their voters. Whether Bernie Sanders’s vigorous run against Hillary Clinton also fits the pattern is a more difficult question — but there was certainly plenty of conflict on display between Democratic party officials and a sizable contingent of Democratic voters.

It’s important to remember, however, that even if the parties’ power over their voters has declined to some extent, they’re still extremely powerful institutions that get their way most of the time. And in Tuesday’s primaries in California, New Jersey and six other states, the parties had a really good night.

That’s not to say that the parties pitched a perfect game. In the U.S. House primary in California’s 50th Congressional District, for example, the Democratic Congressional Campaign Committee’s preferred candidate, Josh Butner, projects to finish only in third or fourth place, behind Republican incumbent Duncan Hunter and another Democrat, Ammar Campa-Najjar. But by luck or design — undoubtedly a bit of both since there were a number of close calls — it looks as though Democrats may avoid having any districts in California where there are no Democrats on the November U.S. House ballot. (In California, the top two finishers advance to the general election regardless of political party, potentially leading to one of the parties being shut out of the November ballot.) That’s a real boon to the Democrats’ prospects in a state where at least nine Republican-held U.S. House seats are potentially in play.

Meanwhile, the Democratic candidates who had the lion’s share of endorsements from party officials finished first in the primaries for U.S. senator and governor in California. In the Senate race, incumbent Sen. Dianne Feinstein easily outdistanced another Democrat, state Sen. Kevin de León, although it looks as though de León will hold on for second place. And in the gubernatorial race, we’ll have a battle between fairly traditional, establishment-backed nominees in Democrat Gavin Newsom, the lieutenant governor, and Republican John Cox.

Sometimes, the parties get their way even if it isn’t necessarily in their electoral best interest. In New Jersey, incumbent senator Bob Menendez was re-nominated, but an obscure Democratic candidate who raised almost no money and who had never held elected office, Lisa McCormick, received 38 percent of the vote. Menendez probably won’t put the seat at risk for the Democrats in November — one recent poll shows a close general election race there, but two others don’t — but with another Democratic nominee who didn’t have Menendez’s baggage, the seat would be almost certain to remain blue. That leaves open the question of whether a better-funded, more recognizable primary challenger could have beaten Menendez, whose popularity waned amid a corruption trial last year. (The trial resulted in a hung jury, and the corruption charges were dismissed earlier this year.) The answer is: possibly yes. Such a candidate would at least have made for a heck of race. It wasn’t a coincidence, however, that no such candidate existed, since the New Jersey Democratic Party has a long history of clearing the field for its preferred nominee.

The Republican establishment also had a good night, including the strong second-place finish for Cox in California. Cox got more of the vote than polls projected after receiving the endorsement of President Trump. Thus, California Republicans will avoid the potential turnout-depressing nightmare of having neither a gubernatorial nor U.S. Senate candidate on the ballot in November.

In Montana, the establishment-backed Matt Rosendale, the state auditor, won the Republican Senate nomination; he’ll face a slightly uphill but by no means unwinnable race against Democratic incumbent Jon Tester. And in South Dakota, the moderate Republican Dusty Johnson, a former chief of staff to Gov. Dennis Daugaard, won the Republican nomination for the at-large U.S. House seat; he’ll probably avoid putting the seat at risk against Democrat Tim Bjorkman, whereas a further-right nominee might have made things more interesting. These results come on the heels of last month’s primaries in West Virginia, which were another fairly successful night for the Republican establishment. Insurgent Don Blankenship finished in a distant third place behind state Attorney General Patrick Morrisey in the U.S. Senate primary.

Again, this is not to suggest that the political parties bat 1.000. Keep in mind, for instance, that there is currently a Democratic senator from Alabama because the state’s Republican Party could not figure out how to prevent its voters from backing an accused child molester, Roy Moore. But these cases are still more the exceptions than the rule, even if the exceptions have become more frequent.

CORRECTION (June 6, 2018, 11:02 a.m.): An earlier version of this article incorrectly described a Republican candidate for the U.S. House seat in South Dakota as the chief of staff to the governor. Dusty Johnson left that position in 2014.