Closes #344 (backport.)