Cherry picking ebb5d3dc336488712c02cdc4bb742e4d4f1055d1

and minor changes
Merge