The most controversial measures in a defense policy bill forcing women to register for the draft and allowing federal contractors to make religious-based hiring decisions have been dropped from the compromise version negotiated by lawmakers.

But lawmakers did approve plans to slash by half the National Security Council to no more than 200 staff positions – a backlash inspired by former defense secretaries’ complaints the NSC is too controlling of foreign policy and military decision-making.

Lawmakers from the House and Senate Armed Service committees agreed on those and other terms as part of a behemoth $618.7 defense bill to fund Pentagon programs and overseas wars, according to committee staff, striking the compromise only after months of wrangling over each chamber’s bills, both of which the White House threatened to veto.

The House plans to vote on the compromise measure this Friday and the Senate will do so next week.

The money includes funds aimed at improving military readiness, reorienting acquisition priorities, and increasing the size of the military services. But negotiations were hampered by a series of policy riders and funding disputes pitting Democrats against Republicans, and Congress against the Obama administration.

Democrats in Congress and the White House objected to language in the House-passed bill to exempt religious organizations with federal government contracts from civil rights law and the Americans with Disabilities Act. The language, introduced by Rep. Steve Russell (R-Okla.), would have effectively overridden a 2014 executive order prohibiting federal contractors from discriminating against workers on the basis of sexual or gender orientation.

Negotiators were still disputing the LGBT language before the pre-election recess, but after President-elect Donald Trump’s win, lawmakers agreed to exclude it. For Republicans, the decision appears to have been helped by Trump’s promise to rip up Obama’s executive orders.

LGBT activists warned that if Trump dismantled Obama’s 2014 executive order, “it would be met with a vociferous backlash not only in the LGBT community but among many Republicans and in the business community as well,” said Ian Thompson of the American Civil Liberties Union.

Republicans won the fight against including language requiring women to begin registering for the Selective Service. Majorities on both the House and Senate Armed Services committees supported the change after the Pentagon announced it would open up combat roles to women. While the Senate-passed bill included the change, House leaders yanked it out of their version before it hit the floor.

Republicans also compromised with Democrats to reduce the maximum size of the NSC from about 400 to 200, a move aimed at limiting the White House reach into the State and Defense Departments’ policy planning operations after former defense secretaries complained of micromanagement.

The final defense policy bill also includes expanded authority to develop the nation’s missile defenses, and an extension and expansion of a program to provide visas to Afghans who worked for the United States military and embassy mission as translators and interpreters, putting another 1,500 visas toward those available. Provisions prohibiting the president from spending money to close the detention facility at Guantanamo Bay were also included.

Committee staffers guessed the compromise should be able to avoid a White House veto, save in one department: The final agreement on funding.

The Obama administration and the GOP-led Congress have long been feuding over defense budget caps, which Republicans have perennially tried to get around by authorizing extra war funds, which aren’t subject to limits. This year, the GOP wanted to authorize an extra $18 billion in war funds to get around budget caps on defense. Democrats, meanwhile, insisted on sticking to spending levels Congress agreed to in a two-year budget deal struck last year.

In the end, lawmakers agreed to dip into an extra $3.2 billion of war funds to cover the $618.7 billion price tag on approved programs.