Revert "Backport #7259 to stable5"

This reverts commit 7bc69c7ea5ca73883ed1b8869929789bf7e85cd7.
Revert "Partially backport #7305 to stable5"

This reverts commit 258997471e919be3e992fc78432397a546417a56.