Some NPE fixing for server and client.