anchor.diff:          ! Initialise real space Hubbard model: find and store the matrix
           ! elements < i | T | j > where i and j are real space basis functions.
   
  -        use basis, only: nbasis, bit_lookup, basis_length, basis_fns, set_orb
  +        use basis, only: nbasis, bit_lookup, basis_lookup, basis_length, basis_fns, set_orb
  +        use determinants, only: decode_det
           use system, only: lattice, ndim, box_length
           use bit_utils
           use checking, only: check_allocate
           use errors, only: stop_all
   
  -        integer :: i, j, k, ierr, pos, ind, ivec
  +        integer :: i, j, k, ierr, pos, ind, ivec, v
           integer :: r(ndim)
   
           integer :: lvecs(ndim, 3**ndim)
  
positive.code:         call check_allocate('tmat',basis_length*nbasis,ierr)
          allocate(connected_orbs(basis_length,nbasis), stat=ierr)
          call check_allocate('connected_orbs',basis_length*nbasis,ierr)
  
          tmat = 0
          connected_orbs = 0
  
negative.code:         if (allocated(tmat)) then
              deallocate(tmat, stat=ierr)
              call check_deallocate('tmat',ierr)
          end if
          if (allocated(connected_orbs)) then
              deallocate(connected_orbs, stat=ierr)
              call check_deallocate('connected_orbs',ierr)
          end if
          if (allocated(connected_sites)) then
              deallocate(connected_sites, stat=ierr)
              call check_deallocate('connected_sites',ierr)
          end if
  
      end subroutine end_real_space_hub
  