changes to support client SA, plus clean/reorg SA code to have less duplication