Refactored parts of trigger_intersect.