Sp 538 - backport for 5595 to 5.0

the first commit is reformatting
three subsequent commits are what they were originally in main branch so that I did not change (squash) them.