Adding Brent's fixes