Also apply #3405 to master branch