Fix some stats bugs in server and client.