Factored out client state into separate struct.