Updated to cope with multi-clients.