Thanks Tim Graham for noticing the issue. Backport of 54caca2d34c7cb6807da0a82bcec7b3a679ac104 from master.