Pre-refactor PR to get 8037 upstreamed in chunks --------- Co-authored-by: Gary Rong <garyrong0905@gmail.com>