[SP] Merge some g_client cleanup/rewrite stuff to SP from MP.