Manually merged changes from the 31 branch