anchor.diff:  
       end subroutine find_processors
       
  -    subroutine particles_per_proc(proc_map, slot_list, nparticles_proc, p_map_size)
  -
  -        ! Find number of particles per processor and store in array nparticles_proc
  +    subroutine particles_per_proc(proc_map, slot_list, nparticles_proc)
  +
  +        ! Find number of particles per processor and store in array nparticles_proc.
  +
           ! In:
  -        !   proc_map: array which maps determinants to processors
  +        !   proc_map: array which maps determinants to processors.
  +        !       proc_map(modulo(hash(d),num_slots*nprocs)=processor.
  +        !   slot_list: array containing populations of slots in proc_map across all
  +        !       processors.
  +        ! Out:
  +        !   nparticles_proc(nprocs): array containing population on each processor.
  +
  +        use parallel, only : nprocs
  +
  +        integer, intent(in) :: proc_map(0:p_map_size-1)
  +        integer(lint), intent(in) :: slot_list(0:p_map_size-1) 
  +        integer(lint), intent(out) :: nparticles_proc(0:nprocs-1)
  +        
  +        integer :: i
  +
  +        nparticles_proc=0  
  +
  +        do i=0, size(proc_map)-1
  +            nparticles_proc(proc_map(i))=nparticles_proc(proc_map(i))+slot_list(i)
  +        end do
  +
  +    end subroutine particles_per_proc
  +
  +    subroutine initialise_slot_pop(proc_map, num_slots, slot_pop)
  +
  +        ! In: 
  +        !   proc_map(p_map_size): array which maps determinants to processors.
           !       proc_map(modulo(hash(d),num_slots*nprocs)=processor
  -        !   p_map_size: length of proc_map
  -        !   slot_list: array containing populations of slots in proc_map across all
  -        !       processors
  -        ! Out:
  -        !   nparticles_proc(nprocs): array containing population on each processor
  -
  -        use parallel, only : nprocs
  -
  -        integer :: i
  -        integer, intent(in) :: p_map_size
  -        integer(lint), intent(out) :: nparticles_proc(nprocs)
  -        integer, intent(in) :: proc_map(p_map_size)
  -        integer(lint), intent(in) :: slot_list(p_map_size) 
  -        nparticles_proc=0  
  -        
  -        do i=1, p_map_size
  -            nparticles_proc(proc_map(i)+1)=nparticles_proc(proc_map(i)+1)+slot_list(i)
  -        end do
  -
  -    end subroutine particles_per_proc
  -
  -    subroutine initialise_slot_pop(slot_pop, proc_map, p_map_size, num_slots)
  -
  +        !   num_slots: number of slots which we divide slot_pop (and similar arrays) into.
           ! In/Out:
           !   slot_pop(p_map_size): array containing population of slots in proc_map
  -        !       processor dependendent
  -        ! In: 
  -        !   proc_map(p_map_size): array which maps determinants to processors
  -        !       proc_map(modulo(hash(d),num_slots*nprocs)=processor
  -        !   num_slots: number of slots which we divide slot_pop into
  +        !       processor dependendent.
   
           use parallel, only: nprocs, iproc
           use hashing 
           use basis, only: basis_length
           use determinants, only: det_info, alloc_det_info, dealloc_det_info
  -       
  +        use fciqmc_data, only: tot_walkers, walker_dets, walker_population
  +
  +        integer, intent(in):: num_slots
  +        integer, intent(in) :: proc_map(0:p_map_size-1)
  +        integer(lint), intent(out) :: slot_pop(0:size(proc_map)-1)        
  + 
           integer :: i, det_pos
  -        integer, intent(in):: p_map_size, num_slots
  -        integer(lint), intent(out) :: slot_pop(p_map_size)        
           type(det_info) :: cdet
  -        integer, intent(in) :: proc_map(p_map_size)
  +
           slot_pop=0
           do i=1, tot_walkers
               cdet%f => walker_dets(:,i)
  -            det_pos=modulo(murmurhash_bit_string(cdet%f, basis_length, 7),num_slots*nprocs)+1
  +            det_pos=modulo(murmurhash_bit_string(cdet%f, basis_length, 7),num_slots*nprocs)
               slot_pop(det_pos)=slot_pop(det_pos)+abs(walker_population(1,i))
           end do
      
  
positive.code: module load_balancing
  
  ! Module for performing load balancing
  ! Determinants are assigned to processors using proc_map(num_slots*nprocs) which 
  ! is initialised so that its entries cyclically contain processors 0,..,nprocs-1
  ! Population for each entry in proc_map is calculated 
  ! Attempt to donate slots from processors with above average populations to those
  ! with below average populations
  
      use loadbal_data
      implicit none
      ! Upper and lower population thresholds
      integer :: up_thresh, low_thresh
      ! How much of a load imbalance is acceptable
      real(dp) :: perc_diff=0.01
      
  contains 
      
      subroutine redistribute_processors(proc_map)
          
          ! Main subroutine in module, carries out load balancing is relatively logical order
          ! In/Out:
          ! proc_map: array which maps determinants to processors
          !       proc_map(modulo(hash(d),num_slots*nprocs)=processor
  
negative.code:         end do
  
      end subroutine reduce_slots
        
      subroutine find_processors(nparticles_proc, up_thresh, low_thresh, rec_dummy, don_dummy, donor_slots, proc_map)
          
          ! Find donor/receiver processors.
          ! Put these into varying size array receivers/donors.
  
          ! In:
          !   nparticles_proc: number particles on each processor.
          !   upper/lower_thresh: upper/lower thresholds for load imblance.
          ! In/Out:
          !   rec_dummy/don_dummy: arrays which contain donor/receivers processors.
          !   donor_slots: number of slots which we can donate, this varies as more entries in proc_map are 
          !       modified.
          !   proc_map: array which maps determinants to processors.
          !       proc_map(modulo(hash(d),num_slots*nprocs)=processor.
  
          use parallel, only: nprocs
          use ranking, only: insertion_rank_int
  
          integer(lint), intent(in) :: nparticles_proc(0:nprocs-1)
          integer, intent(in) :: proc_map(0:p_map_size-1)
          integer, intent(in) :: up_thresh, low_thresh
          integer, intent(inout) :: donor_slots
  
          integer ::  i, j, k, upper, lower
          integer, allocatable, dimension(:) ::  tmp_rec, tmp_don, rec_sort
          integer, allocatable :: rec_dummy(:), don_dummy(:)
          integer :: rank_nparticles(nprocs)
  
          allocate(tmp_rec(nprocs))
          allocate(tmp_don(nprocs))
          k=1
          j=1
  
          ! Find donors/receivers processors.
          
          do i=0, size(nparticles_proc)-1
              if(nparticles_proc(i) .lt. low_thresh) then
                  tmp_rec(j)=i
                  j=j+1
              else if (nparticles_proc(i) .gt. up_thresh) then
                  tmp_don(k)=i
                  k=k+1
              end if 
          end do
          
          ! Put processor ID into smaller array.
          
          allocate(rec_dummy(j-1))
          allocate(rec_sort(j-1))
          allocate(don_dummy(k-1))
  
          don_dummy=tmp_don(:k-1)
          rec_dummy=tmp_rec(:j-1)
  
          ! Sort receiver processers.
          
          call insertion_rank_int(nparticles_proc, rank_nparticles, 0) 
          do i=1, size(rec_dummy)
              rec_sort(i)=rank_nparticles(i)
          end do
          rec_dummy=rec_sort
  
          ! Calculate number of donor slots which we can move.
          
          donor_slots=0
          do i=0, size(proc_map)-1
              do j=1, size(don_dummy)
                  if(proc_map(i)==don_dummy(j)) then
                      donor_slots=donor_slots+1
  