           if rule.is_transposable_with ((x) -> blockTfm[x])
             symmetries.push tfm
   return symmetries
-
-unwrapResult = (result) ->
-      #console.log "#### Result found:"+JSON.stringify(result)
-      #Result may be a real result object, or a reference to another. Dereference, if needed
-      if (referenced = result.refersTo)?
-        referenced
-      else
-        result
-
+  
 exports.MemoAnalyser = class MemoAnalyser
   constructor: (@rule)->
     @ruleset = rule.stabilize_vacuum()

    Cells.sortXY pattern
    key = patternKey pattern
    if (result = @pattern2result[key])?
      return unwrapResult result
    else
      result = {resolution:null} #result would be calculated later - now only make an empty placeholder
      @registerResult pattern, result, key
                
    bestPatternSearch = new Maximizer Cells.energy
    bestPatternSearch.put pattern

    @maxPopulation = 1024
    @maxSize = 100
    @symmetries = ruleSpatialSymmetries rule
    @frozen = false
    @doubleHitCount = 0
    @currentPatternKeys = []

  freeze: ->
    @frozen = true
    @truncateTable

  stashKeys: (pattern, mainKey) ->
    keys = @currentPatternKeys
    keys.push mainKey
    for tfm in @symmetries
      transformedKey = patternKey Cells.transform pattern, tfm
      keys.push transformedKey
    return
    
  writeResult: (result) ->
    pattern2result = @pattern2result
    for key in @currentPatternKeys
      pattern2result[key] = result
    @currentPatternKeys = []
    return

  analyse: (pattern) ->
    result = @_analyse pattern
    result.hits += 1
    if result.hits is 2
      @doubleHitCount += 1
    return result

  _analyse: (pattern) -> #result
