With Christophe's suggested diff and small changes.