backport pull request #1023 from master