Autodiscover function improved (not based on filesystem anymore)