Pennsylvania lives in a cave when it comes to modern elections, critics say, but fast-tracked legislation that was quietly negotiated behind closed doors could usher in some advancement.

The bill, should it pass, didn't come easily: Partisan jockeying, 11th-hour blowups and brinksmanship dogged what could be the most substantive changes to Pennsylvania's election laws in more than 80 years.

"We've attacked the election code very little, so Pennsylvania is ranked in the very bottom tier of states in the country," said Micah Sims, executive director of Common Cause's Pennsylvania chapter. "That's why this moment right now is huge for Pennsylvania."

For now, negotiators -- Democratic Gov. Tom Wolf and leaders of the House and Senate Republican majorities -- are waiting to see whether the bill can overcome objections from rank-and-file lawmakers.

Many states long ago adopted farther-reaching changes to election laws, including automatically registering people to vote when they turn 18, allowing election-day voter registration and opening polling places for early in-person voting.

This bill won't do that, and Wolf didn't get Republicans to embrace every election reform he had sought.

But Wolf did get wins, including expanding voting access and securing millions of dollars for counties to buy voting machines ahead of the 2020 elections.

Under the bill, voters can register up to 15 days before the election. Among states, Pennsylvania's current 30-day deadline is the furthest out, according to the National Conference of State Legislatures.

Also, the bill allows any voter to mail in a ballot for any reason, adding Pennsylvania to a group of 31 states that already do so, according to the NCSL. Currently, Pennsylvania restricts mail-in ballots to "absentee" voters who meet a narrow set of reasons.

With a lawsuit pending over Pennsylvania's deadlines for counties to receive absentee ballots, the bill adjusts those deadlines to 8 p.m. on election days. Currently, the deadline is 5 p.m. on the Friday before the election, the nation's earliest.

The bill is part of a broader deal to deliver $90 million in state aid to counties to help them afford voting machines. Wolf had initially sought $75 million toward a total price tag that could exceed $125 million.

Wolf last year began pressing counties to buy voting machines with an auditable paper backup, contending it would bolster Pennsylvania's election security after warnings by federal authorities that Russian hackers had targeted states during 2016's election.

The big win in the bill for Republicans? Eliminating the ballot option that allows voters to push one button that selects a single political party's candidate in each contest.

After objecting to Wolf's demand for new voting machines, Republicans made eliminating the straight-party ticket voting option a condition of any legislation that sends state voting-machine dollars to counties.

The demand emerged amid Republican worries that moderate voters, angry at President Donald Trump, will simply pull the lever for Democrats in next year's election, endangering down-ballot Republicans in Pennsylvania's suburbs.

Closed-door talks on the package started after Wolf vetoed Republican-backed legislation in July that packaged $90 million in voting-machine aid with the elimination of the straight-party ticket voting option. Top Republicans hadn't negotiated the bill with him, and it didn't include his election-reform priorities, he had said.

One 11th-hour addition to the bill injected more intrigue.

Wording submitted by Senate Republicans removes the Department of State, which oversees elections, from the role of directing campaigns to provide receipts that show how campaign cash was spent. It instead makes a person seeking the receipts go to court against a defiant campaign.

Pushback grew Tuesday when two news organizations, Spotlight PA and The Caucus, published a story about how some Pennsylvania state lawmakers had reported campaign spending on food, booze and travel as simply credit card payments or expense reimbursements, then took months to provide receipts.

The new provision raised red flags with watchdog groups, and lawmakers said they will remove it.

The bill could pass as early as Wednesday, giving counties six months until the 2020 primary to absorb changes that, with compressed voter-registration deadlines and more mail-in votes, promise a bigger workload.

"People need to be aware that there's a workload attached to it," said Douglas Hill, executive director of the County Commissioners Association of Pennsylvania. "And we're going to do what we need to go to rise to the challenge."