Backport of developments from the master as part of task 6845.
assigned to @p.const
mentioned in commit 4a60ab68
merged