Nested discovery fixes

Sorry for the lack of tests.  Hopefully I'll get to this tomorrow.
ah i see