Lot of work on cleanup the client connect functionality