anchor.diff:                              time = time - timestep(R)
                               if ( time > t_barrier ) exit
   
  -                            call ct_spawn(cdet, spawned_walkers(spawned_pop,idet), nspawned, connections)
  -                            
  +                            call ct_spawn(cdet, spawned_walkers(spawned_pop,current_pos(iproc)), nspawned, connections)
  +                           
  +                            ! Handle walker death
  +                            if(connections%nexcit == 0 .and. &
  +                            spawned_walkers(spawned_pop,current_pos(iproc))*nspawned < 0) then
  +                                spawned_walkers(spawned_pop,current_pos(iproc)) = spawned_walkers(spawned_pop,current_pos(iproc) + nspawned 
  +                                exit
  +                            end if
  +
                               ! add a walker to the end of the spawned walker list in the
                               ! appropriate block - this will increment the appropriate
                               ! spawning heads for the processors which were spawned on
  
positive.code:                 if(all(current_pos == spawning_head+1)) exit
                  
              end do
          end do
  
      end subroutine do_tc_fciqmc
  
      
      subroutine ct_spawn(d, parent_sgn, nspawned, connection)
      
          ! randomly select a (valid) excitation from the current determinant
          ! stored in "d"
          !
          ! In: 
          !    d: info on current determinant that we will spawn from.
          !    parent_sgn: sgn on the parent determinant (i.e. +ve or -ve integer)
          !
          ! Out:
  
negative.code:         !    connection: the excitation connection between the parent and child
          !                determinants
  
          use excitations, only: enumerate_all_excitations
          use dSFMT_interface, only: genrand_real2
          use system, only: ndim, nel
  
          type(det_info), intent(in) :: det
          integer, intent(in) :: parent_sgn
          real(p), intent(in) :: K_ii, matel
          
          integer, intent(out) :: nspawned
          type(excit), intent(out) :: connection
          
          real(p) :: rand, test, R_ii, R, abs_matel
          integer :: num_excitations
          type(excit) :: connection_list(2*ndim*nel)
  
          R_ii = abs(H_ii)
          abs_matel = abs(matel)
          call enumerate_all_excitations_real(d, num_excitations, connection_list)
          R = R_ii + matel*num_excitations
          rand = genrand_real2()*R
  
          if (rand < R_ii) then
              connection%nexcit = 0 ! spawn onto the same determinant (death/cloning)
              if (K_ii < 0) then    ! child is same sign as parent
                  nspawned = sign(1,parent_sgn)
              else if (K_ii > 0) then
                  nspawned = -sign(1,parent_sgn)
              else
                  nspawned = 0
              end if
          else
              test = R_ii
              do j = 2, nexcit
                  test = test + abs_matel
                  if (rand < test) then
                      if (K_ii < 0) then ! child is same sign as parent
                          nspawned = sign(1,parent_sgn)
                      else if (K_ii > 0)
                          nspawned = -sign(1,parent_sgn)
                      else
                          nspawned = 0
                      end if
                      connection = connection_list(j)
                      exit
                  end if
              end do
          end if
  
      end subroutine ct_spawn_real
  
  
      subroutine create_spawned_particle_ct(d, connection, time, nspawned, spawned_pop)
  
  