Still more bug fixes (rebased onto dev_4_4)

Same as gh-529, rebased onto dev_4_4.