Small changes to fivef/SankarNatarajan's version