CLEARWATER: CP-4042 

A combo pull request for clearwater replicating PRs 1034, 1063, 1065 and 1145

This needs careful review as there was quite a lot of conflict resolution required.