backport. closes #460, #552