Upstream changes from hg