Refactor to client.c.