These are backported via cherry-pick from the branch by @theuni that was merged in #8133. Only minor fixups were needed in two of the seven commits.
'make check' tests pass but so far this has only been tested on Ubuntu 16.04; we'll see what Travis has to say.