Splitting into separate client/server implementations.

- Should be refactored more to avoid duplication.