Moved discovery to be more reusable.