Regression in b52c73008a9d67e9ddbb841872dc15cdd3d6ee01. Backport of 5fa390ee81c5a963fc4476e8de6c1e5e1fc57e22 from master