Some fixes to discover function