Update discovery code, fix build; misc API changes