   redraw()
 
 doStep = ->
-  cells = evaluateWithNeighbors cells, getNeighbors, transitionFunc
+  cells = evaluateWithNeighbors cells, getNeighbors, transitionFunc.evaluate.bind(transitionFunc)
   redraw()
 
+#Flag to avoid requestAnimationFrame congestion. It really helps a lot!
+frameRequested = false
 redraw = ->
   s = Math.min( canvas.width, canvas.height ) / 2
-  window.requestAnimationFrame ->
-    context.clearRect 0, 0, canvas.width, canvas.height
-    context.save()
-    context.scale s, s
-    context.translate 1, 1
-    drawVisibleCells visibleCells, cells, tfm, tessellation, context
-    context.restore()  
+
+  if not frameRequested
+    frameRequested = true
+    window.requestAnimationFrame ->
+      frameRequested = false
+      context.clearRect 0, 0, canvas.width, canvas.height
+      context.save()
+      context.scale s, s
+      context.translate 1, 1
+      drawVisibleCells visibleCells, cells, tfm, tessellation, context
+      context.restore()
+
+updatePopulation = ->
   #console.log "Redraw. Population is #{cells.count}"
-  #E("population").innerHTML = ""+cells.count
+  E("population").innerHTML = ""+cells.count
 
 toggleCellAt = (x,y) ->
   s = Math.min( canvas.width, canvas.height ) * 0.5

  xyk = dx*dy*k
  yyk = dy*dy*k
  
  moveMatrix =[xxk+1, xyk,   dx,
               xyk,   yyk+1, dy,
               dx,     dy,     dt]
  tfm = M.mul moveMatrix, tfm
  redraw()
    
rotateView = (angle) ->
  s = Math.sin angle
  c = Math.cos angle
  rotMatrix = [c, s, 0.0,
               -s,  c, 0.0,
               0,  0, 1.0]
  tfm = M.mul rotMatrix, tfm
  redraw()        
  
redraw()
class MovingDragger
  constructor: (@x0, @y0) ->
  mouseMoved: (e)->
    [x, y] = getCanvasCursorPosition e, canvas

  context.fill()
  return      
  
mooreNeighborhood = (n, m, appendRewrite)->(chain)->
  #reutrns Moore (vertex) neighborhood of the cell.
  # it contains N cells of von Neumann neighborhood
