Add ancestor queries to stablize results, and general clean up.