Refactoring according to new client-server protocol.