Add client model; fix bugs