Added global boolean to prevent autodiscover() from being called more than once.