Import changes from pull #1070.