Incorporated latest changes from upstream.