Client: getting very close to a usable main loop