Minimized diff from upstream.