fix some issues when changing identity.