Refactor: Extract read and write to client

Read and write operations towards the client are now functions of
their own