anchor.diff:        
      END IF
   
  -      
  +   call cleanup()
  +   
   contains
      subroutine cleanup()
         call AD_DestroyOutput(            y_p, ErrStat2, ErrMsg2 )
  
positive.code:    
     do j=1,p%NumTwrNds
        
        V_rel = u%InflowOnTower(:,j) - u%TowerMotion%TranslationDisp(:,j) ! relative wind speed at tower node
     
        tmp   = u%TowerMotion%Orientation(1,:,j)
        VL(1) = dot_product( V_Rel, tmp )            ! relative local x-component of wind speed of the jth node in the tower
  
negative.code:       call AD_DestroyConstrState( z_m, ErrStat2, ErrMsg2 ) ! we don't need this any more      
        
     END IF
     
     call cleanup()
  contains
     subroutine cleanup()
        m%BEMT%UseFrozenWake = .false.
  