Thanks Baptiste Mispelon for the patch and dave.lampton@ for the suggestion. Backport of c852d456 from master.