With seven election-related lawsuits pending, a federal judge clashed Wednesday with lawyers for state officials, national Republicans and U.S. Sen. Bill Nelson’s campaign in a case about whether voters whose ballot signatures don’t match those on file should be able to “cure” the ballots.

“I’m being asked to rewrite the election code of the state of Florida, one piece at a time,” U.S. District Judge Mark Walker groused during a five-hour hearing about the state’s process for handling mismatched signatures on mail-in and provisional ballots.

Nelson’s campaign and the Democratic Executive Committee of Florida want Walker to override a law that requires signatures on absentee and provisional ballots to match the signatures on file with election offices.

Voters whose mail-in ballots are received by 5 p.m. the day before the election have an opportunity to “cure” their ballots, by providing documentation to elections supervisors to show that they are who they claim to be.

But voters whose mail-in ballots come in after the deadline — or who cast provisional ballots on Election Day — aren’t afforded the same opportunity. And county canvassing boards, which decide whether ballots are legitimate, handle the mismatched signatures differently, lawyers for Nelson and the Democrats argued during the hearing.

Seeking a fourth term in the U.S. Senate, Nelson trails Republican Gov. Rick Scott by about 12,500 votes, down from Scott’s 56,000-vote lead on election night.

Wednesday’s hearing came before a 3 p.m. Thursday deadline for county elections offices to submit the results of machine recounts in the Senate race and the races for governor and agriculture commissioner. The Nelson-Scott contest is almost certain to fall within a 0.25 percent margin that will require a subsequent manual recount.

It was not immediately clear when Walker will rule on the ballot-signature issue. It also was unclear exactly how many ballots with mismatched signatures have been tossed out statewide. But 45 of Florida’s 67 counties have rejected 3,668 ballots due to mismatched signatures, according to Maria Matthews, director of the state Division of Elections.

Among the counties not included in the totals were highly populated Duval and Miami-Dade counties, Matthews told Walker. The final number of rejected ballots could be around 5,000, Walker estimated.

Matthews said it appeared Nelson’s team wanted “ballots to be counted without verifying the signature of the voter,” something that she warned could “create a little bit of confusion.”

“I’m concerned about the fact that counties have been operating pretty much non-stop since before the election,” she said, adding that counting the additional ballots could “increase the number of errors.”

Walker bristled when Mohammad Jazil, an attorney representing Matthews’ boss, Secretary of State Ken Detzner, asked Matthews if she, like other elections officials, was tired.

“I can assure you the most tired person in the room is me. Let’s move on,” scolded Walker, who frequently took Republican lawyers to task during the hearing.

But Nelson’s lawyer, Uzoma Nkwonta, argued that the state should delay election deadlines to give voters whose ballots were scrapped an opportunity to fix them. Official results from the election are scheduled to be certified Tuesday.

“There’s zero reason why this election and the recount and the certification of votes needs to occur on Nov. 20,” Nkwonta argued, saying that to comply with the statutory deadlines would “disenfranchise thousands of voters.”

Nkwonta told Walker that voters need more than three days to have the opportunity to fix their ballots.

“At least a couple of weeks from now, if not more, given the Thanksgiving holiday,” Nkwonta said.

But Walker questioned how involved the court should get in the elections process, noting that it was “almost laughable” that the parties in the courtroom were taking opposite stances from their positions in an Arizona recount in which Democratic U.S. Senate candidate Kyrsten Sinema emerged the victor after a recount.

“Isn’t it just fundamentally a bad idea to have a federal judge essentially being asked to rewrite the entire election code as ballots are being counted?” Walker asked. “This just seems like a really bad way to do this.”

Nkwonta acknowledged the concern over the number of lawsuits.

“But these are real, live issues,” he said.

Jazil, however, said Walker’s own remedy in a similar lawsuit two years ago was working.

Siding with the Florida Democratic Party and the Democratic National Committee shortly before the 2016 general election, Walker ordered Detzner to come up with a way to allow voters to “cure” ballots that were rejected. Walker called the state law “indefensible” and said it threatened to disenfranchise voters.

“The remedy seems to be working,” Jazil said. “The numbers are going down.”

But that drew the ire of Walker.

“Unless you’re one of the people who got notified in the mail seven days after the election” that their ballots had been rejected, he said.

“Sorry, bud. You’re disenfranchised,” the judge said.

But Jazil insisted that the state’s deadlines have to stick, in part because of a Jan. 8 date when the new governor and Cabinet members will be sworn in.

If the executive branch elections aren’t settled by then, the Legislature chooses the governor and Cabinet members, Jazil argued.

“I cannot think of anything greater that would undermine … people’s faith in our democracy” than to have the state officials selected by the Legislature, Jazil said.

“I think there are a great many things that are undermining people’s faith in our democracy,” Walker retorted.

The judge seemed unpersuaded by arguments that counting the additional ballots would throw the elections process into chaos, appearing to reject the Republicans’ arguments that the extra votes could spark additional recounts in races that have already been decided.

Walker asked why he shouldn’t issue an order giving voters an opportunity to cure their ballots “between now and the evening of the 17th,” or the day before manual recounts have to be completed.

“I don’t understand why that’s going to completely bring Florida to its knees,” he said.

Walker, who lectured the lawyers throughout the lengthy hearing, ripped into Deputy Attorney General Jordan Pratt for suggesting the federal judge didn’t have the authority to strike down the state law.

If that was the case, an angry Walker said, Florida schools would still be segregated.

Walker saved some of his venom for Thomas Dupree, a lawyer representing the National Republican Senatorial Committee, who agreed with the judge that the legal challenge puts Walker in an “extremely difficult position of having to sort out winners and losers” in the election.

But Walker lashed out at Dupree, who argued that Nelson and the Democrats had waited too long to file their lawsuit. That would mean “every candidate who’s going to run in 2020 needs to run to the courthouse now and dissect the statute,” Walker said.

“Every judge in the country would be, ‘Bye-bye. You’ve got no standing,’ ” Walker said.

Walker also appeared to reject Jazil’s argument that voting by mail is a “convenience” granted to voters but is not constitutionally required.

“Implicit in all this is, ‘get off your lazy butt and go vote in a polling place,’ ” Walker said.

But Jazil said the state was trying to ensure that votes are cast by people “who are who they say they are” while accommodating voters by allowing them to vote by mail.

“We’re being asked to throw a wrench into a sequential, statutory process,” Jazil said.

But Walker balked again.

“I really don’t understand how that’s going to destroy the system and bring it to its knees,” he said.