Timob 12558 3 0 x -- Backport

While I'm making the pull request, the changes were originally done by @mstepanov and @steipete. CR and FR has passed already. Will be merging.