Cherry pick from master for 5.2