server and client: small refactoring