Properly handle sort and search for nested joins.
First part of reworking reseller handling.