Fixed $clientID discovery issue and added debug logging