manual cherrypick of 46724
This MR is a manual cherry-pick of the changes in !46724 (merged) (merged) (merged) to fix ATEAM-780 for branch 21.0-mc16d. But it seems the two branches (master and 21.0-mc16d) diverged quite a lot and there were conflicts. I tried to resolve them but there are much more changes in this MR as in the original MR !46724 (merged) (merged) (merged). @ssnyder , can you please take a loo whether this MR is ok?
Edited by Peter Berta