Fix compilation warnings from !51758
!51758 (merged) was auto-merged and some compilation warnings were leftover.
This MR fixes them.
Also it's an opportunity for experts to comment on !51758 (merged) and suggest better solutions.
Edited by Tadej Novak