Incorporated changes from upstream master