Ported over fixes of Adriaan did in branch buildFor2.11.0-M7.