Fixed potential crash in the server.

Be more defensive!