Backport features from master branch
3.1.0