Client refactor for M3

Work in progress