Refactoring.
Client handler extracted from server.