Port aed562bb8230c0ce18308fde77d350f84f7c5b99 on master

@jfarcand Please review (and good luck with that!).