Thanks Tim Graham for the review. Backport of 0204714b0b from master
0204714b0b
Backport of 38c17871bb from master
38c17871bb