Back-port changes from the master branch