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: ! excitations.
  integer(i0), allocatable :: connected_orbs(:,:) ! (basis_length, nbasis)
  
  ! connected_sites(:,i) contains the list of sites connected to site i (ie is the
  ! decoded/non-bit list form of connected_orbs).
  ! If connected_orbs(j,i) is 0 then it means there are fewer than 2ndim sites
  ! that are connected to i that are not a periodic image of i.
  integer, allocatable :: connected_sites(:,:) ! (2ndim, nbasis)
  
  ! True if any site is its own periodic image.
  ! This is the case if one dimension (or more) has only one site per crystal
  ! cell.  If so then the an orbital can incur a kinetic interaction with itself.
  