For the election-obsessed among us, the two months of turbulence that followed last November's elections for Virginia's House of Delegates would be hard to top for its riveting back-and-forth legal drama and fingernail-biting suspense.

Now, as the nation heads into midterm elections on which might hinge party control not only of several state legislatures but also of both houses of Congress, it's not implausible to imagine similar dramas playing out across the country. Virginia's experience holds some key lessons that policymakers and election administrators in other states should be moving quickly to follow.

Close races -- even an occasional deadlock -- aren't unprecedented among the nearly 6,500 federal and state legislative races held every two years across the country. But Virginia's election officials found themselves in the national spotlight largely due to an outcome that few if any political observers saw coming: Democrats flipped a remarkable 15 House seats on Nov. 7, 12 of them by defeating incumbents. Only by ultimately prevailing in both the District 28 and District 94 contests were Republicans able to cling to a 51-49 majority.

Not surprisingly, many journalists couldn't resist the analogy to another close election that involved razor-thin margins and disputed ballots. As a New York Times headline put it in late December, "Virginia Voting Mess Was Never Supposed to Happen After Bush v. Gore." But Virginia election officials are hardly deserving of Florida 2000-like scorn.

Their administration of last November's voting certainly wasn't perfect; the mis-assignment of District 28 voters, for example, was a non-trivial mistake. Still, it's important to understand some key things Virginia election officials did right that allowed them to dodge what might have been a far-worse catastrophe. The most important step Virginia took -- and just in the nick of time -- was to revert to paper ballots and ditch its high-tech, ATM-like voting machines.

A little history is instructive here. In the wake of the Florida 2000 debacle, Congress passed the Help America Vote Act, appropriating several billion dollars to help states jettison the widely derided punch-card ballots that had made "hanging chads" a permanent part of the American political lexicon. Like many states, Virginia used the money to abandon paper-based ballots altogether in favor of software-enabled voting machines known in the parlance as "Direct Recording Election" (DRE) devices. But in 2013, Virginia election officials realized that about 3,000 of these DREs, then being used by about 20 percent of the state's voters, were especially vulnerable to software hacks.

Virginia's Board of Elections issued an emergency order to local election officials to de-commission these machines prior to the 2015 gubernatorial election. Then, last July at the annual DEF CON hackers' conference in Las Vegas, many of the state's remaining DRE machines were shown to be vulnerable. Rather than hold fast to its original plan -- to phase out and replace these machines by 2020 -- the elections board forced local officials in 22 jurisdictions to move to paper-ballot systems in time for last November's election.

This bold move became unexpectedly important -- even prescient -- when the results were so close in four legislative races that recounts were required. These recounts could now be based entirely on paper ballots marked directly by voters.

Today, an estimated 50 million voters in 28 states and the District of Columbia still cast their ballots on DRE machines. Eleven of these states rely wholly or partly on older and especially vulnerable machines that don't generate a paper trail. When a recount is needed, election officials can do little more than re-run the software program -- hardly a reassuring move if there are suspicions of hacking.

Some of those states have made or are contemplating massive investments in newer machines capable of generating what's known as a "Verified Voter Paper Audit Trail." Ohio alone may shell out $118 million for such an upgrade. But recounts using those newer machines still would rely heavily on software code. "There's simply no way to do a meaningful recount on any DRE machine," says Marian Schneider, president of the nonprofit advocacy group Verified Voting.

Paper ballots do present their own challenges, foremost among them how to adjudicate voter intent when ballots are marked in strange ways. But here again, Virginia election officials deserve kudos. Over the years, they have worked with leaders in both parties to develop and refine an official manual on how to discern voter intent when hand-counting ballots. More than a hundred examples of actual ballots can be found among the manual's 15 pages, and doubtless more will be added as a result of the 2017 recounts. The document's thoroughness -- the result of painstaking work largely done during the quiet times between elections -- gave the 2017 recounts credibility, illustrated by the praise even Republican officials gave to the process after Democrat Simonds emerged with a one-vote lead in the District 94 race.

There was, however, one glaring flaw in Virginia's system that deserves redress, though it had nothing to do with any shortcomings on the part of election officials. It left a cloud that Virginia lawmakers should move to immediately fix and which other states should ponder as well.

It's a long-standing principle of American jurisprudence that while appellate courts can review whether the law was correctly applied, they cannot substitute their own judgment when it comes to determining the facts of a case. But with the District 94 recount, that's exactly what the three-judge panel did in agreeing to re-litigate the facts of a disputed ballot. They then compounded their judicial over-reach by not allowing other questionable ballots to be brought forward.

So (at least) two cheers, Virginia elections officials, for a job remarkably well done under difficult circumstances. Let's hope others will take the necessary steps to do even better when it's their turn in the hot glare of the election-administration spotlight.