Backport commit f7f9b88cd1cca301e8a63f97396fc3390793a123