anchor.diff:      implicit none
       real(dp),intent(in)    :: t, e
       integer,intent(in)    :: i, iw
  -    if(debug) print *,'[debug] inserting t,i=',t, iw, i
  -    if(t < tmin .and. t > 0._dp) then
  -       tmin = t
  -       imin = no_wall
  -       if(iw == 1) then
  -          imin%w1 = i
  -       else if(iw == 2) then
  -          imin%w2 = i
  -       else
  -          imin%w3 = i
  +    real(dp) :: emax
  +    if(debug) print *,'[debug] inserting t,i=',t, e, iw, i
  +    if(t > 0._dp) then
  +       emax = max(e, emin)
  +       if(t < tmin - emax) then
  +          tmin = t
  +          imin = no_wall
  +          emin = emax
  +          if(iw == 1) then
  +             imin%w1 = i
  +          else if(iw == 2) then
  +             imin%w2 = i
  +          else
  +             imin%w3 = i
  +          end if
  +       else if(t < tmin + emax) then
  +          emin = emax
  +          if(iw == 1) then
  +             imin%w1 = i
  +          else if(iw == 2) then
  +             imin%w2 = i
  +          else
  +             imin%w3 = i
  +          end if
          end if
       end if
     end subroutine insert_t
   
  -  subroutine find_next_wall(on_wall,t,i)
  -    implicit none
  -    logical(1),intent(in)  :: on_wall
  +  subroutine find_next_wall(t,i)
  +    implicit none
       real(dp),intent(out)    :: t
       type(wall_id),intent(out)    :: i
       t = tmin
  
positive.code:     call quadratic_pascal_reduced(pB,pC_1,t1,t2)
      if(p%on_wall_id%w1 == -1) then
         if(abs(t1) < abs(t2)) then
            call insert_t(t2, 1, -1, e)
         else
            call insert_t(t1, 1, -1, e)
         end if
      else
         call insert_t(t1,1, -1,e)
         call insert_t(t2,1, -1,e)
      end if
  
      ! Outer wall
  
negative.code: 
      if(p%on_wall_id%w2 /= -1) then
         t1 = ( geo%w2(p%icell%i2)   - p%r%z ) / p%v%z
         call insert_t(t1,2, -1, 0._dp)
      end if
      if(p%on_wall_id%w2 /= +1) then
         t2 = ( geo%w2(p%icell%i2+1) - p%r%z ) / p%v%z
         call insert_t(t2,2, +1, 0._dp)
      end if
  
      ! -------------------------------------------------
  