.list file
  maxListComplexSize = maxComplexSize;
  //printf("maxComplexSize=%d\n",maxComplexSize);
  nNewComplexes = nNewPerms = 0;
  int CLastLine = 0;
  int * lastCLine = malloc(nStrands * sizeof(int));
  if( F_list!= NULL) {
    while( fgets( line, MAXLINE, F_list)) {
      sscanf(line, "%1s", firstChar);

      if( firstChar[0] == '%') {
        continue;
      }
      if( firstChar[0] == 'C') {
        if(CLastLine) {
          nNewPerms += makeFCPermutations(NULL,lastCLine,complexSize,nStrands);
        }
        nNewComplexes++;
        complexSize = 0;
        token = strtok( line, " ");
        CLastLine = 1;
        for( i = 0; i < nStrands; i++) {
          token = strtok( NULL, " ");
          if(!token ||  sscanf( token, "%d", &nMonomer)!= 1) {
            printf("Error in list file, line: %s\n", line);
            exit(1);
          }
          lastCLine[i] = nMonomer;

          complexSize += nMonomer;
        }

        // Check to make sure input complex size is greater than max complex size
        if (complexSize <= maxComplexSize) {
          printf("Error in list file.  All complexes in list file must be\n");
          printf("greater than maximum complex size specified in input file.\n");
          exit(1);
        }
        if( complexSize > maxListComplexSize)
          maxListComplexSize = complexSize;
      }
      else if( isdigit( firstChar[0]) ) {
        CLastLine = 0;
        nNewPerms++;
      }
    }
    if(CLastLine && complexSize > maxComplexSize) {
      nNewPerms += makeFCPermutations(NULL,lastCLine,complexSize,nStrands);
    }
  }

  //determine total # of distinct strand orders (lovasz, 3.23b)
  totalOrders = nNewPerms;
  for( i = 1; i <= maxComplexSize; i++) {
    for( j = 1; j <= i; j++) {

      totalOrders += pow( nStrands, gcd( j, i))/i;
    }
  }
  nTotalOrders = totalOrders + 0.1;

  //Next, generate all multisets
  nSets = binomial_coefficient(maxComplexSize + nStrands,maxComplexSize) - 1;
  if(nSets < 1) {
    fprintf(stderr,"Integer overflow occurred while counting permutations!\n");
    exit(1);
  }

  totalSets = nSets + nNewComplexes;

  if( globalArgs.out == 1) {
    printHeader( nStrands, seqs, maxComplexSize, nTotalOrders,
                nSets, nNewComplexes, F_cx, argc, argv, 0);
    if( globalArgs.permsOn) {
      printHeader( nStrands, seqs, maxComplexSize, nTotalOrders,
                  nSets, nNewComplexes, F_ocx, argc, argv, 0);
      printHeader( nStrands, seqs, maxComplexSize, nTotalOrders,
                  nSets,
                  nNewComplexes, F_perm, argc, argv, 0);
    }

    if( globalArgs.mfe) {
      printHeader( nStrands, seqs, maxComplexSize,
                  nTotalOrders, nSets,
                  nNewComplexes, F_permMfe, argc, argv, 0);
    }

    if( globalArgs.dopairs) {
      printHeader( nStrands, seqs, maxComplexSize, nTotalOrders,
                  nSets,
                  nNewComplexes, F_cxAvg, argc, argv, 1);
      if( globalArgs.permsOn) {
        printHeader( nStrands, seqs, maxComplexSize, nTotalOrders,
                    nSets,
                    nNewComplexes, F_permPr, argc, argv, 1);
        printHeader( nStrands, seqs, maxComplexSize, nTotalOrders,
                    nSets,
                    nNewComplexes, F_permAvg, argc, argv, 1);

      }
    }
    if(globalArgs.dodefect) {
      printHeader(nStrands, seqs, maxComplexSize, nTotalOrders,
                  nSets, nNewComplexes, F_defect, argc, argv, 1);
      fprintf(F_defect,"%%\n");
      fprintf(F_defect,"%% Ensemble defects n(s,phi) and normalized ensemble defects n(s,phi)/N\n");
      fprintf(F_defect,"%% Comp\tPerm\t");
      int i_strand;
      for(i_strand = 0 ; i_strand < nStrands; i_strand++) {
        fprintf(F_defect, "S%i\t", i_strand+1);
      }
      fprintf(F_defect,"n(s,phi)\tn(s,phi)/N\tStruc Prob\tPart Func\n");
    }
  }

  // Generate all necklaces for each length with order nStrands

  int cursize = 1;
  permutation * allPermutations = (permutation*)
                    malloc(nTotalOrders * sizeof(permutation));
  int added = 0;
  int offset = 0;
  for(cursize = 1; cursize <= maxComplexSize ; cursize++) {
    added = makePermutations(allPermutations + offset,cursize,nStrands);
    offset += added;
  }
  totalOrders2 = offset;

  if( F_list!= NULL) {
    rewind( F_list); //go to beginning of prefix.list

    //Get extra sets and perms from prefix.list
    offset = totalOrders2;
    int curStrand;
    int curStrandIndex;
    int curNumStrands;
    int list_file_line = 0;
    int warning_printed = 0;
    CLastLine = 0;

    while(NULL!= fgets(line,MAXLINE,F_list)) {
      list_file_line ++;
      strncpy(line2,line,MAXLINE);
      token = strtok(line,",\t\n");
      if(token == NULL) {
        continue;
      }
      if(token[0] == '%') {
        continue;
      }
      if(token[0] == 'C') {
        if(!warning_printed) {
          printf("Warning: 'C' lines in the list file are deprecated please specify ordered complexes directly\n");
          warning_printed = 1;
        }

        if(CLastLine) {
          curNumStrands = 0;
          for(curStrand = 0 ; curStrand < nStrands ; curStrand++) {
            curNumStrands += lastCLine[curStrand];
          }
          offset += makeFCPermutations(allPermutations + offset, lastCLine, curNumStrands, nStrands);
        }

        curStrand = 0;
        token = strtok(NULL,",\t\n");
        while(NULL!= token && curStrand < nStrands) {
          if(! sscanf(token, "%d", &curNumStrands)) {
            fprintf(stderr,"Error on line %d: encountered %s\n",list_file_line,token);
            exit(1);
          }
          lastCLine[curStrand] = curNumStrands;
          token = strtok(NULL,",\t\n");
          curStrand++;
        }

        CLastLine = 1;
        continue;
      }

      if(0 == sscanf(token, "%d", &curStrand)) {
        fprintf(stderr,"Error on line %d: encountered %s\n",list_file_line,token);
        exit(1);
      }

      curNumStrands = 0;
      while(NULL!= token) {
        if(0 == sscanf(token, "%d", &curStrand)) {
          fprintf(stderr,"Error on line %d: encountered %s\n",list_file_line,token);
          exit(1);
        }
        curNumStrands++;
        