The second time’s the charm.

In 2016, I came to the Comedy Cellar in Greenwich Village to give election-night commentary on a panel featuring pundits and comics. I went home in shock and spent a restless night tossing and turning with the realization that a capricious and ignorant reality-TV star had been elected president of the United States.

I tempted fate by returning to the Comedy Cellar on Tuesday night to comment on the midterms. Early in the evening, I had the queasy feeling so familiar from 2016 as FiveThirtyEight’s election tracker kept lowering the odds of Democrats taking the House and raising the odds of Republicans holding the Senate. But by the time our panel adjourned at 11 p.m., CNN had called the House for the Democrats, even as Republicans increased their edge in the Senate.

I went home to a restful night’s sleep, because there was some good news to cheer, even though the midterm results were not all that I had hoped for. I wanted to see a root-and-branch repudiation of the Trumpist transformation of the Republican Party. The race-baiting and immigrant-bashing were particularly squalid in the last weeks of the campaign — and President Trump was hardly the sole culprit. Other Republicans did not denounce his despicable tactics and even imitated them. A friend in Florida, for example, sent me a last-minute email from the Palm Beach County Republican Party warning GOP voters that “George Soros, Andrew Gillum and their people are looking for ‘pay back for our 2016 victory’! Don’t allow their money, influence or tricks to ruin this election or your family’s future!” “Their people”? “Their money”? This wasn’t dog-whistling. This was a wolf-whistle to white voters suspicious of wealthy Jews such as Soros and powerful African Americans such as Gillum. Sadly, it worked: Gillum lost after leading in pre-election polls.

So, too, another talented African American gubernatorial candidate, Stacey Abrams, was trailing in Georgia in another campaign laced with racial undertones. Abrams’s opponent, Brian Kemp, misused his position as Georgia’s secretary of state to suppress the minority vote and then made unfounded, last-minute allegations of voter-roll hacking against the Democrats.

It speaks badly of our country that such unscrupulous tactics paid off in so many races. The fact that the GOP went there confirms its transformation from a Reagan-Ryan conservative party into a white-nationalist party in Trump’s image. If you think the immigrant-bashing was offensive this year, imagine what it will be like in two years when Trump himself is on the ballot.

But — and here’s the reason I could sleep at night — Trump’s contemptible campaign did not help Republicans hold the House. To the contrary, it sparked a backlash in suburban districts among more moderate, better-educated voters. There is, I am happy to report, quite a lot of decency left in America. Hence the blue wave that swept the Republicans out of the House majority. The irony is that many of the Republicans who lost, such as Carlos Curbelo in Florida and Barbara Comstock in Northern Virginia, were relative moderates — albeit moderates who never did much to stand up to Trump. The remaining House GOP caucus, indeed the entire GOP, is likely to be Trumpier than ever, even as the majority of the country expresses its disgust with Trumpism.

But with the Democrats in control of the House, there will finally, belatedly, be some pushback. There are so many scandals to investigate, it is difficult to know where to start. This is the most dishonest administration in history, and it cries out for accountability. Imagine what Rep. Richard E. Neal (D-Mass.), the possible new chairman of the House Ways and Means Committee, will discover if, as is his right, he requests the president’s long-hidden tax returns from the Internal Revenue Service.

The glass-is-half-full nature of the election outcome is most evident at the Justice Department. The GOP’s enlarged Senate majority will make it easier for Trump to get rid of Attorney General Jeff Sessions and Deputy Attorney General Rod J. Rosenstein and replace them with lickspittles eager to obstruct justice on the president’s behalf. But the Democratic majority in the House will make it impossible for Trump’s lackeys to bury special counsel Robert S. Mueller III’s report: Democrats can subpoena his findings.

Partisan rancor, already high, will reach stratospheric levels in the next two years. But that is the price of checks and balances — which have been mainly lacking so far. The election results restore some of my faith in our democracy, but I am sobered by the realization that the battle is far from over. It could last another two years, or even six years. It is quite possible the Democrats will overplay their hand and that Trump will use his demagogic skills to win reelection. To paraphrase Winston Churchill, this is not the end of Trumpism. It is not even the beginning of the end. But it is, perhaps, the end of the beginning.

Read more: