Better overlapping instances check

@garyb @jdegoes @joneshf  Mind reviewing this?

This is asymptotically slower than the old check, but I think it is more robust, and easier to understand.