partial manual backport of #31114 (omitted parts that were not directly relevant due to different structure in v4, without the overview)
partial manual backport of #31114 (omitted parts that were not directly relevant due to different structure in v4, without the overview)