anchor.diff:                  do i = 1, nbeta_combinations
   
                       ! Get beta orbitals.
  -                    if (i == 1) then
  -                        f_beta = first_perm(nbeta)
  -                    else
  -                        f_beta = bit_permutation(f_beta)
  -                    end if
  -
  -                    call decode_bit_string(f_beta, occ)
  -                    ! Convert to beta orbitals.
  -                    occ = 2*(occ+1)
  +                    call next_string(i==1, .false., nbasis/2, nbeta, d0%occ_list_beta, &
  +                                     d0%unocc_list_beta, truncation_level, comb(:,1),  &
  +                                     occ(1:nbeta), excit_level_beta)
  +
                       ! Symmetry.
                       ! Have to treat the UEG as a special case as we don't consider
                       ! all possible symmetries for the UEG but rather only momenta
  
positive.code: 
          deallocate(occ, stat=ierr)
          call check_deallocate('occ', ierr)
  
      end subroutine find_sym_space_size
  
  
negative.code:         integer, intent(in), optional :: occ_list0(nel)
  
          integer :: i, j, iel, ierr
          integer :: nbeta_combinations
          integer, allocatable :: nalpha_combinations(:)
          integer :: sym_beta, sym, Ms, excit_level_alpha, excit_level_beta
          integer(i0) :: f_alpha, f_beta, f0(basis_length), f(basis_length)
          integer, allocatable :: occ(:), comb(:,:)
          integer :: k(ndim), k_beta(ndim)
          type(det_info) :: d0
  
          if (allocated(sym_space_size)) then
              deallocate(sym_space_size, stat=ierr)
  