Backported commit aafcf967687a8c943178a1d23d8a957592fd3933