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

    @maxPopulation = 1024
    @maxSize = 100
    @symmetries = ruleSpatialSymmetries rule

  registerResult: (pattern, result, mainKey) ->
      #Register a pattern with given result, under all keys
      pattern2result = @pattern2result
      pattern2result[mainKey] = result
      for tfm in @symmetries
        transformedKey = patternKey Cells.transform pattern, tfm
        if transformedKey isnt mainKey
          #assert that key either not present, or refers the same result
          #if pattern2result[transformedKey]?
          #  
          pattern2result[transformedKey] = result


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

  _analyse: (pattern) -> #result

          if rule.is_transposable_with ((x) -> blockTfm[x])
            symmetries.push tfm
  return symmetries
  
exports.MemoAnalyser = class MemoAnalyser
  constructor: (@rule)->
    @ruleset = rule.stabilize_vacuum()
