anchor.diff:          ! truncation_level+2 excitors.
           ! Following the process described by Thom in 'Initiator Stochastic
           ! Coupled Cluster Theory' (unpublished), each size, n_s, has probability
  -        ! p(n_s) = 1/2^(n_s+1), n_s=0,truncation_level and p(truncation_level+2)
  -        ! is such that \sum_{n_s=0}^{truncation_level+2} p(n_s) = 1.
  +        ! p(n_s) = 1/2^(n_s+1), n_s=0,max_level-1 and p(max_level)
  +        ! is such that \sum_{n_s=0}^{max_level} p(n_s) = 1, and hence
  +        ! p(max_level) = 1/2^max_level.
           rand = genrand_real2()
  -        psize = 0.0_p
  +        psize_sum = 0.0_p
           cluster%nexcitors = -1
  -        do i = 0, truncation_level+1
  -            psize = psize + 1.0_p/2**(i+1)
  -            if (rand < psize) then
  +        do i = 0, max_cluster_size -1
  +            psize = 1.0_p/2**(i+1)
  +            psize_sum = psize_sum + psize
  +            if (rand < psize_sum) then
                   ! Found size!
                   cluster%nexcitors = i
  -                cluster%pselect = cluster%pselect/2**(i+1)
                   exit
               end if
           end do
  -        ! If not set, then must be the largest possible cluster
  -        if (cluster%nexcitors < 0) then
  -            cluster%nexcitors = truncation_level + 2
  -            cluster%pselect = cluster%pselect*(1.0_p - psize)
  +        ! If reached end of loop, then must be the largest possible cluster.
  +        if (i == max_cluster_size) then
  +            cluster%nexcitors = max_cluster_size
  +            psize = 1.0_p/2**max_cluster_size
           end if
  +        cluster%pselect = cluster%pselect*psize
   
           select case(cluster%nexcitors)
           case(0)
  
positive.code: 
      end subroutine do_ccmc
  
      subroutine select_cluster(nattempts, D0_pos, cdet, cluster)
  
          ! Select a random cluster of excitors from the excitors on the
          ! processor.  A cluster of excitors is itself an excitor.  For clarity
  
negative.code:         use utils, only: factorial
  
          integer(lint), intent(in) :: nattempts
          integer, intent(in) :: D0_pos, max_cluster_size
          type(det_info), intent(inout) :: cdet
          type(cluster_t), intent(inout) :: cluster
  
          real(p) :: rand, psize, psize_sum
          integer :: i, pos, cluster_population
  
          ! We shall accumulate the factors which comprise cluster%pselect as we go.
  