More work on discovery refactoring.