A federal judge Tuesday gave final approval to Volkswagen’s $14.7 billion settlement of its emissions-cheating scandal, clearing the way for buyback payments to begin soon to nearly half a million diesel-car owners who were driving vehicles that don’t conform to U.S. pollution laws.

The written ruling also allows VW owners the option of keeping their cars and having them modified by the carmaker to meet air quality standards.

U.S. District Judge Charles Breyer, who had heard objections to the proposed settlement in an Oct. 18 hearing, said Tuesday that the agreement “adequately and fairly compensates” owners, according to a copy of the final ruling. “Given the risks of prolonged litigation, the immediate settlement of this matter is far preferable,” Breyer wrote.

The final settlement in a San Francisco court brings to an end a year of waiting for as many as 475,000 owners of the 2.0-liter diesel models that were found to be rigged to pass government lab tests. In the ruling, Breyer also approved VW’s $1.2 billion settlement with about 650 U.S. dealerships.

The Environmental Protection Agency and other federal and state agencies sued VW, which has acknowledged fitting VW and Audi diesel vehicles from the 2009-15 model years with defeat-device software to pass smog tests. People who bought or leased the sporty cars — billed as  “clean diesel” vehicles — were offered a temporary deal, subject to public comment, after the scandal broke in September 2015.

The final settlement offers restitution amounts of $5,100 to $9,852 plus the value of the vehicle based on various factors including the year, make, model and current mileage of the vehicle. For owners taking the buyback, the combined total could range anywhere from $12,475 to $44,175.

Under the settlement, Volkswagen (and “related entities”) will spend up to $10.03 billion to compensate owners of the affected vehicles and $4.7 billion to mitigate pollution from the cars and invest in green auto technology.

About 340,000 owners of affected cars have registered to take part in the settlement, according to Reuters, and now have to decide how to make the most of the agreement. About 3,500 owners have elected to opt out.

“Given the high claim rate and the low opt-out and objection rates, this factor strongly favors final approval,” Breyer wrote in his ruling.

September 2018 is the deadline for VW owners to accept the buyback offer or wait for the to-be-announced emissions system fix. Meanwhile, in addition to its tarnished reputation, VW may have further troubles: Emissions of other diesel engines it makes are still being investigated.

Philip Reed is a staff writer at NerdWallet, a personal finance website. Email: preed@nerdwallet.com.

The article Judge Approves $14.7 Billion Settlement in VW Diesel Scandal originally appeared on NerdWallet.