Backport pull request #54 as a hotfix to v2.7

See pull request #54