Minor improvement to intersection function.