Export the discover function. Fix a nesting problem.