Cherrypick of c7d908, c79779, ccab6