apply more of Pierre Goupil's changes