Fix few bugs related with client disconnection