Backported 8f6a4cac91e6591b74bf7bc6bcc58a5a3096b05e to 4.4.