Regression in b52c73008a9d67e9ddbb841872dc15cdd3d6ee01. Backport of f3b69f9757ec03057441ebbd52b7cdbfed31fb32 from master.