Recommitted parts of bb8ef151e4676c16459bfac3287312f3c261d698