Havana merge mopup

Recover commits that were missed in the 3.2->4.0 master branch rebase.

Replaces #843 and #847.