cherry picked bae1f39, part 1