Merge changes from tip into 0.5 branch.