Cleanup: Removed a lot of deprecated methods
diff --git a/lib/Krawfish/Koral/Corpus.pm b/lib/Krawfish/Koral/Corpus.pm
index 776d62c..22d0ecc 100644
--- a/lib/Krawfish/Koral/Corpus.pm
+++ b/lib/Krawfish/Koral/Corpus.pm
@@ -25,17 +25,6 @@
 # Query Planning methods and attributes #
 #########################################
 
-sub plan_for_new {
-  my ($self, $index) = @_;
-  $self
-    ->normalize
-    ->finalize
-    ->refer
-    ->inflate($index)
-    ->cache
-    ->optimize($index);
-};
-
 
 # Normalize the query
 sub normalize {
@@ -126,20 +115,6 @@
 };
 
 
-# Expand regular expressions
-sub inflate {
-  my ($self, $dict) = @_;
-
-  warn 'DEPRECATED - use identify';
-
-  my $ops = $self->operands;
-  return $self unless $ops;
-  for (my $i = 0; $i < @$ops; $i++) {
-    $ops->[$i] = $ops->[$i]->inflate($dict);
-  };
-  return $self;
-};
-
 
 # TODO:
 #   If "nothing" returns, optimize away
diff --git a/lib/Krawfish/Koral/Corpus/Field.pm b/lib/Krawfish/Koral/Corpus/Field.pm
index af3de8b..a027b4f 100644
--- a/lib/Krawfish/Koral/Corpus/Field.pm
+++ b/lib/Krawfish/Koral/Corpus/Field.pm
@@ -111,20 +111,11 @@
 sub can_toggle_negativity;
 
 
-sub inflate {
-  # Inflate for RegEx and existence!
-  warn 'Inflation on fields not yet implemented';
-  return $_[0];
-};
 
-
-# This is alternative to inflate
+# Translate all terms to term ids
 sub identify {
   my ($self, $dict) = @_;
 
-  # Do not inflate
-  # TODO:
-  #   But identify!!!
   unless ($self->is_regex) {
 
     my $term = $self->to_term;
diff --git a/lib/Krawfish/Koral/Meta.pm b/lib/Krawfish/Koral/Meta.pm
index 9dbc34b..bbc7cc1 100644
--- a/lib/Krawfish/Koral/Meta.pm
+++ b/lib/Krawfish/Koral/Meta.pm
@@ -16,8 +16,6 @@
 
 
 our %META_ORDER = (
-  #  snippet   => 1,
-  #  fields    => 2,
   limit     => 1,
   sort      => 2,
   enrich    => 3,
@@ -237,221 +235,8 @@
   ...
 };
 
-1;
-
-
-__END__
-
-
-sub items_per_page {
-  my $self = shift;
-  return $self->{items_per_page} unless @_;
-  $self->{items_per_page} = shift;
-  return $self;
-};
-
-
-sub start_index {
-  my $self = shift;
-  return $self->{start_index} unless @_;
-  $self->{start_index} = shift;
-  return $self;
-};
-
-
-sub facets {
-  my $self = shift;
-  return $self->{facets} unless @_;
-  $self->{facets} = [@_];
-  return $self;
-};
-
-
-# Count doc_freq and freq
-sub count {
-  my $self = shift;
-  return $self->{count} unless @_;
-  $self->{count} = shift;
-  return $self;
-};
-
-
-# Get lengths of results
-sub length {
-  my $self = shift;
-  return $self->{length} unless @_;
-  $self->{length} = shift;
-  return $self;
-};
-
-
-sub prepare_for {
-  shift->plan_for(@_);
-};
-
-
-# Check if the meta query is filterable
-sub sort_filter {
-  my ($self, $query, $index) = @_;
-
-  # No sort defined
-  return $query unless $self->{field_sort};
-
-  # Sort is not restricted
-  return $query unless $self->{items_per_page};
-
-  # Filtering not applicable because
-  # all matches need to be found
-  if ($self->{facets} ||
-        $self->{field_count} ||
-        $self->{count} ||
-        $self->{length}) {
-    return $query;
-  };
-
-  # Get first run field
-  my ($field, $desc) = @{$self->{field_sort}->[0]};
-
-  # Create rank filter
-  $query = Krawfish::Result::Sort::Filter->new(
-    query        => $query,
-    max_rank_ref => $self->max_doc_rank_ref,
-    field        => $field,
-    desc         => $desc,
-    index        => $index
-  );
-
-  print_log('kq_meta', 'Query is qualified for sort filtering') if DEBUG;
-
-  return $query;
-};
-
-
-# Return max_doc_rank reference
-sub max_doc_rank_ref {
-  my $self = shift;
-
-  # Set value to reference
-  ${$self->{max_doc_rank_ref}} = shift if @_;
-
-  return $self->{max_doc_rank_ref};
-};
-
-
-sub plan_for {
-  my ($self, $index) = @_;
-
-  # Get the query
-  my $query = $self->{query} or return;
-
-
-  # TODO:
-  #   The dictionary should also have a max_rank!
-
-
-  # Get the maximum rank for fields, aka the document number
-  # and init the shared value for faster filtering
-  my $max_doc_rank_ref = $self->max_doc_rank_ref($index->max_rank);
-
-  # Prepare the nested query
-  $query = $query->prepare_for($index);
-
-  my @aggr;
-  # Add facets to the result
-  if ($self->{facets}) {
-
-    # This should have more parameters, like count
-    foreach (@{$self->{facets}}) {
-      push @aggr, Krawfish::Result::Segment::Aggregate::Facets->new($index, $_);
-    };
-  };
-
-  # Count field values
-  if ($self->{field_count}) {
-
-    # This should have more parameters, like count
-    foreach (@{$self->{field_count}}) {
-      push @aggr, Krawfish::Result::Segment::Aggregate::Values->new($index, $_);
-    };
-  };
-
-  # Add frequency and document frequency count to result
-  # TODO:
-  #   This may be obsolete in some cases, because other aggregations already
-  #   count frequencies.
-  if ($self->{count}) {
-    push @aggr, Krawfish::Result::Segment::Aggregate::Frequencies->new;
-  };
-
-  if ($self->{length}) {
-    push @aggr, Krawfish::Result::Segment::Aggregate::Length->new;
-  };
-
-  # Augment the query with aggregations
-  # TODO:
-  #   It may be better to have one aggregation object, that can be filled!
-  #   like ->query($query)->aggregate_on($aggr)->prepare_for($index);
-  #   and after the query is through, the aggregation map contains data
-  if (@aggr) {
-    $query = Krawfish::Result::Segment::Aggregate->new($query, \@aggr);
-  };
-
-  # Sort the result
-  # This is mandatory!
-
-  # Precalculate top_k value
-  my $top_k = undef;
-  if ($self->items_per_page) {
-
-    # Top k is defined
-    $top_k = $self->items_per_page + ($self->start_index // 0);
-  };
-
-  # TODO:
-  #   Check for fields that are either not part
-  #   of the index or are identified in
-  #   the corpus query (it makes no sense to
-  #   sort for author, if author=Fontane is
-  #   required)
-  $query = Krawfish::Result::Sort::PriorityCascade->new(
-    query => $query,
-    index => $index,
-    fields => $self->{field_sort},
-    unique => UNIQUE_FIELD,
-    top_k => $top_k,
-    max_rank_ref => $max_doc_rank_ref
-  );
-
-  print_log('kq_meta', "Field sort with: " . $query->to_string) if DEBUG;
-
-
-  # Limit the result
-  if ($self->items_per_page || $self->start_index) {
-    $query = Krawfish::Result::Limit->new(
-      $query,
-      $self->start_index,
-      $self->items_per_page
-    );
-  };
-
-  # The order needs to be:
-  # snippet(
-  #   fields(
-  #     limit( -
-  #       sorted( -
-  #         faceted( -
-  #           count(Q) -
-  #         )
-  #       )
-  #     )
-  #   )
-  # )
-
-  # Return the query
-  return $query;
-};
-
 
 1;
 
+
 __END__
diff --git a/lib/Krawfish/Koral/Meta/Enrich.pm b/lib/Krawfish/Koral/Meta/Enrich.pm
index d4b54c4..713c222 100644
--- a/lib/Krawfish/Koral/Meta/Enrich.pm
+++ b/lib/Krawfish/Koral/Meta/Enrich.pm
@@ -1,5 +1,4 @@
 package Krawfish::Koral::Meta::Enrich;
-use Krawfish::Koral::Meta::Node::Enrich;
 use Krawfish::Log;
 use strict;
 use warnings;
diff --git a/lib/Krawfish/Koral/Meta/Node/Aggregate/Length.pm b/lib/Krawfish/Koral/Meta/Node/Aggregate/Length.pm
deleted file mode 100644
index ca93b06..0000000
--- a/lib/Krawfish/Koral/Meta/Node/Aggregate/Length.pm
+++ /dev/null
@@ -1,53 +0,0 @@
-package Krawfish::Koral::Meta::Node::Aggregate::Length;
-use Krawfish::Result::Segment::Aggregate::Length;
-#use Krawfish::Util::String qw/squote/;
-use Krawfish::Query::Nothing;
-use strict;
-use warnings;
-
-
-warn 'DEPRECATED';
-
-# Create new enrichment object for fields
-sub new {
-  my $class = shift;
-  my $self = '';
-  bless \$self, $class;
-};
-
-
-sub to_string {
-  'length';
-};
-
-
-# This will identify the query and create a list of sorted fields ids
-sub identify {
-
-  warn 'DEPRECATED';
-
-  my ($self, $dict) = @_;
-
-  $self->{query} = $self->{query}->identify($dict);
-
-  return $self;
-};
-
-
-# Materialize query for segment search
-sub optimize {
-  my ($self, $segment) = @_;
-
-  my $query = $self->{query}->optimize($segment);
-
-  if ($query->max_freq == 0) {
-    return Krawfish::Query::Nothing->new;
-  };
-
-  return Krawfish::Result::Segment::Aggregate::Length->new(
-    $segment,
-    $query
-  );
-};
-
-1;
diff --git a/lib/Krawfish/Koral/Meta/Node/Enrich.pm b/lib/Krawfish/Koral/Meta/Node/Enrich.pm
deleted file mode 100644
index 6662f4a..0000000
--- a/lib/Krawfish/Koral/Meta/Node/Enrich.pm
+++ /dev/null
@@ -1,60 +0,0 @@
-package Krawfish::Koral::Meta::Node::Enrich;
-use Krawfish::Log;
-use strict;
-use warnings;
-
-use constant DEBUG => 1;
-
-sub new {
-  my $class = shift;
-
-  warn 'DEPRECATED';
-
-  my $self = bless {
-    query => shift,
-    enrichments => shift
-  }, $class;
-};
-
-
-
-# Get identifiers
-sub identify {
-  my ($self, $dict) = @_;
-
-  warn 'DEPRECATED';
-
-  
-  my @identifier;
-  foreach (@{$self->{enrichments}}) {
-    my $enrich = $_->identify($dict);
-
-    if ($enrich) {
-      push @identifier, $enrich;
-    };
-  };
-
-  $self->{query} = $self->{query}->identify($dict);
-
-  return $self->{query} if @identifier == 0;
-
-  $self->{enrichments} = \@identifier;
-
-  return $self;
-
-};
-
-
-sub to_string {
-  my $self = shift;
-
-  warn 'DEPRECATED';
-
-  return 'enrich(' .
-    join(',', map { $_->to_string } @{$self->{enrichments}}) .
-    ':' . $self->{query}->to_string . ')';
-};
-
-
-
-1;
diff --git a/lib/Krawfish/Koral/Meta/Sort.pm b/lib/Krawfish/Koral/Meta/Sort.pm
index d626b54..f4da685 100644
--- a/lib/Krawfish/Koral/Meta/Sort.pm
+++ b/lib/Krawfish/Koral/Meta/Sort.pm
@@ -99,15 +99,6 @@
 };
 
 
-# TODO:
-#   REMOVE!
-sub to_nodes {
-  my ($self, $query) = @_;
-  warn 'DEPRECATED';
-  return Krawfish::Result::Node::Sort->new($query, [$self->operations]);
-};
-
-
 sub wrap {
   my ($self, $query) = @_;
   return Krawfish::Koral::Meta::Node::Sort->new(
@@ -118,6 +109,7 @@
   );
 };
 
+
 sub to_string {
   my $self = shift;
   my $str = join(',', map { $_->to_string } @{$self->{sort}});
@@ -159,11 +151,6 @@
   $self->{top_k} = shift;
 };
 
-# Order sort
-sub plan_for {
-  my ($self, $index, $query) = @_;
-  ...
-};
 
 
 sub type { 'sort' };
@@ -189,72 +176,3 @@
 
 
 __END__
-
-# Sorting can be optimized by an appended filter, in case there is no need
-# for counting all matches and documents.
-#
-# This can be added to the query using
-# ->filter_by($sort->filter)
-sub filter {
-  my $self = @_;
-
-  # The filter should be disabled, because all matches need to be counted!
-  if (defined $_[0]) {
-    $self->{filterable} = shift;
-    return;
-  };
-
-  # Filter is disabled
-  return unless $self->{filterable};
-
-  # return Krawfish::Result::Sort::Filter->new(
-  #   $self->{corpus}
-  # );
-  ...
-};
-
-
-sub plan_for {
-  my ($self, $index) = @_;
-
-  my $field = shift @{$self->{fields}};
-
-  # TODO: Sorting should simply use
-  # Krawfish::Result::Sort and the passes
-  # should be handled there!
-
-  # Initially sort using bucket sort
-  $query = Krawfish::Result::Sort::FirstPass->new(
-    $self->{query},
-    ($field->[0] eq 'desc' ? 1 : 0),
-    $field->[1]
-  );
-
-  # Iterate over all fields
-  foreach $field (@{$self->{fields}}) {
-    $query = Krawfish::Result::Sort::Rank->new(
-      $query,
-      ($field->[0] eq 'desc' ? 1 : 0),
-      $field->[1]
-    );
-  };
-
-  # Final sorting based on UID
-  return Krawfish::Result::Sort->new($query, 0, 'uid');
-};
-
-
-sub type { 'sort' };
-
-
-sub to_koral_fragment {
-  ...
-};
-
-
-sub to_string {
-  ...
-};
-
-
-1;
diff --git a/lib/Krawfish/Koral/Query.pm b/lib/Krawfish/Koral/Query.pm
index 038f91b..9293f6a 100644
--- a/lib/Krawfish/Koral/Query.pm
+++ b/lib/Krawfish/Koral/Query.pm
@@ -50,17 +50,6 @@
 # Query Planning methods and attributes #
 #########################################
 
-sub plan_for_new {
-  my ($self, $index) = @_;
-  $self
-    ->normalize
-    ->finalize
-    ->refer
-    ->inflate($index->dict)
-    ->cache
-    ->optimize($index);
-};
-
 
 # Normalize the query
 sub normalize;
@@ -72,20 +61,6 @@
 };
 
 
-# Expand regular expressions
-sub inflate {
-  my ($self, $dict) = @_;
-
-  warn 'Inflate is deprecated - use ->identify()';
-
-  my $ops = $self->operands;
-  return $self unless $ops;
-  for (my $i = 0; $i < @$ops; $i++) {
-    $ops->[$i] = $ops->[$i]->inflate($dict);
-  };
-  return $self;
-};
-
 
 # TODO:
 #   If "nothing" returns, optimize away
diff --git a/lib/Krawfish/Koral/Query/Constraints.pm b/lib/Krawfish/Koral/Query/Constraints.pm
index ba81984..c25ac9a 100644
--- a/lib/Krawfish/Koral/Query/Constraints.pm
+++ b/lib/Krawfish/Koral/Query/Constraints.pm
@@ -304,36 +304,6 @@
 
 
 # Inflate operands and constraints
-sub inflate {
-  my ($self, $dict) = @_;
-
-  warn 'DEPRECATED in favor of identify!';
-
-  my $ops = $self->operands;
-
-  # Inflate on all operands
-  my $i = 0;
-  for (; $i < @$ops; $i++) {
-    $ops->[$i] = $ops->[$i]->inflate($dict);
-
-    if ($ops->[$i]->is_nothing) {
-      # Return new nothing operand
-      return Krawfish::Koral::Query::Nothing->new;
-    };
-  };
-
-  my $cs = $self->constraints;
-
-  # Inflate all constraints
-  for ($i = 0; $i < @$cs; $i++) {
-    $cs->[$i] = $cs->[$i]->inflate($dict);
-  };
-
-  return $self;
-};
-
-
-# Inflate operands and constraints
 sub identify {
   my ($self, $dict) = @_;
 
diff --git a/lib/Krawfish/Koral/Query/Span.pm b/lib/Krawfish/Koral/Query/Span.pm
index 6f1b23a..3e0e679 100644
--- a/lib/Krawfish/Koral/Query/Span.pm
+++ b/lib/Krawfish/Koral/Query/Span.pm
@@ -25,13 +25,16 @@
   }, $class;
 };
 
+
 sub type { 'span' };
 
+
 # There are no classes allowed in spans
 sub remove_classes {
   $_[0];
 };
 
+
 sub to_koral_fragment {
   my $self = shift;
   my $span = {
@@ -50,14 +53,6 @@
   return $_[0];
 };
 
-#sub inflate {
-#  my ($self, $dict) = @_;
-
-#  print_log('kq_span', 'Inflate span') if DEBUG;
-
-#  $self->{operands}->[0] = $self->operand->inflate($dict);
-#  return $self;
-#};
 
 
 sub identify {
diff --git a/lib/Krawfish/Koral/Query/Term.pm b/lib/Krawfish/Koral/Query/Term.pm
index 74eb863..2643fb1 100644
--- a/lib/Krawfish/Koral/Query/Term.pm
+++ b/lib/Krawfish/Koral/Query/Term.pm
@@ -340,42 +340,10 @@
 };
 
 
-sub inflate {
-  my ($self, $dict) = @_;
-
-  # Do not inflate
-  return $self unless $self->is_regex;
-
-  # Get terms
-  my $term = $self->to_term_escaped;
-
-  print_log('kq_term', 'Inflate /^' . $term . '$/') if DEBUG;
-
-  # Get terms from dictionary
-  my @terms = $dict->terms(qr/^$term$/);
-
-  if (DEBUG) {
-    print_log('kq_term', 'Expand /^' . $term . '$/');
-    print_log('kq_term', 'to ' . (@terms > 0 ? substr(join(',', @terms), 0, 50) : '[0]'));
-  };
-
-  # Build empty term instead of nothing
-  return $self->builder->nothing unless @terms;
-
-  # TODO:
-  #   Use refer?
-  return $self->builder->bool_or(@terms)->normalize;
-};
-
-
-
-# This is alternative to inflate
+# Translate all terms to term_ids
 sub identify {
   my ($self, $dict) = @_;
 
-  # Do not inflate
-  # TODO:
-  #   But identify!!!
   unless ($self->is_regex) {
 
     my $term = $self->to_term;
diff --git a/lib/Krawfish/Koral/Query/TermGroup.pm b/lib/Krawfish/Koral/Query/TermGroup.pm
index 79b40d8..0cfd419 100644
--- a/lib/Krawfish/Koral/Query/TermGroup.pm
+++ b/lib/Krawfish/Koral/Query/TermGroup.pm
@@ -12,7 +12,7 @@
 # TODO:
 #   Preparation should be:
 #   -> normalize()
-#   -> inflate()
+#   -> identify()
 #   -> finalize()
 #   -> memoize(cache)
 #   -> optimize(index)
diff --git a/lib/Krawfish/Koral/Query/Token.pm b/lib/Krawfish/Koral/Query/Token.pm
index 428aa3a..7a8e898 100644
--- a/lib/Krawfish/Koral/Query/Token.pm
+++ b/lib/Krawfish/Koral/Query/Token.pm
@@ -105,13 +105,6 @@
 };
 
 
-sub inflate {
-  my ($self, $dict) = @_;
-  print_log('kq_token', 'Inflate wrapper') if DEBUG;
-  $self->operands([$self->operand->inflate($dict)]);
-  return $self;
-};
-
 sub finalize {
   my $self = shift;
 
diff --git a/lib/Krawfish/Koral/Result.pm b/lib/Krawfish/Koral/Result.pm
index 631302e..dba4c2e 100644
--- a/lib/Krawfish/Koral/Result.pm
+++ b/lib/Krawfish/Koral/Result.pm
@@ -41,82 +41,3 @@
 1;
 
 __END__
-
-use Krawfish::Koral::Result::Group;
-
-
-sub new {
-  my $class = shift;
-  bless {
-    query => shift,
-    group_by => undef
-  }, $class;
-};
-
-
-sub group_by {
-  my ($self, $type, $param) = @_;
-  $type = lc $type;
-  if ($type eq 'fields') {
-    $self->{group} = Krawfish::Koral::Result::Group->by_fields(@$param);
-  };
-  return $self;
-};
-
-
-# Prepare for index
-sub prepare_for {
-  my ($self, $index) = shift;
-
-  my $koral_query;
-
-  # TODO: Prepare corpus
-  # TODO: Prepare query
-
-  # Group was set
-  if ($self->{group}) {
-
-    my $criterion = $self->{group};
-    $koral_query = Krawfish::Result::Group->new(
-      $koral_query,
-      $criterion,
-      $index
-    );
-  };
-};
-
-sub add_match {
-  my ($self, $posting, $index) = @_;
-
-  my $match = Krawfish::Koral::Result::Match->new($posting);
-
-  my $meta = $self->meta;
-  if ($meta->fields) {
-    $match->fields(
-      $index->get_fields($posting->doc_id, $meta->fields)
-    );
-  };
-
-  # Expand match to, e.g., <base/s=s>
-  if ($meta->expansion) {
-    my ($start, $end) = $index->get_context(
-      $posting,
-      $meta->expansion
-    );
-  };
-
-  # Expand context to, e.g., <base/s=p>
-  if ($meta->context) {
-    my ($start) = $index->get_context();
-  };
-
-  if ($meta->snippet) {
-    $self->get_snippet(
-      posting => $posting,
-      highlights => $meta->highlights,
-      snippet_context => $meta->context,
-      match_context => $meta->expansion,
-      annotations => $match->annotations
-    );
-  };
-};