Improved detection for overlap with rectangles