refs #279 Some fixes to bad parts of the cherry-pick got lost in the final rebase
before pushing to master. Here they are.