Clean rebase of rodboev's #5746 (rebase-first). Co-authored-by: rodboev <rodboev@users.noreply.github.com>