code: private boolean insertGap() throws StructureException,
  			RefinerFailedException {
  
  		// Let gaps only if the repeat is larger than the minimum length
  		if (repeatCore <= Lmin)
  			return false;
  
  		// Select residue by maximum distance
  		updateMultipleAlignment();
  		Matrix residueDistances = MultipleAlignmentTools
  				.getAverageResidueDistances(msa);
  
  		double maxDist = Double.MIN_VALUE;
  		int su = 0;
  		int res = 0;
  		for (int col = 0; col < length; col++) {
  			for (int s = 0; s < order; s++) {
  				if (residueDistances.get(s, col) != -1) {
  					if (residueDistances.get(s, col) > maxDist) {
  						// geometric distribution
  						if (rnd.nextDouble() > 0.5) {
  							su = s;
  							res = col;
  							maxDist = residueDistances.get(s, col);
  						}
  					}
  				}
  			}
  		}
  
  		// Insert the gap at the position
  		Integer residueL = block.get(su).get(res);
  		if (residueL != null) {
  			freePool.add(residueL);
  			Collections.sort(freePool);
  		} else
  			return false; // If there was a gap already in the position.
  
  		block.get(su).set(res, null);
  		checkGaps();
  		return true;
  	}
docs: Insert a gap in one of the repeats into selected position (by higher
  distances) in the alignment. Calculates the average residue distance to
  make the choice. A gap is a null in the block.
  
  @throws StructureException
  @throws RefinerFailedException