Some refactorings in ClientHandler.