     
     func setup() 
     {
-        cubeCount = 0
-        numrows = randint(30)+10
-        
-        // start at centre
+        size.y = randint(60)+30 // number of cube rows, used to calculate cubeSize
+        
         let (cw, ch) = cubeSize()
-        pos = (width()/cw/2 , numrows/2)
-
         size.x = width()/cw
-        size.y = height()/ch
-        
+
         center.x = size.x/2
         center.y = size.y/2
-                
+
+        pos = center // start at centre
+                        
         keepdir[0] = 0.1 + randflt() * 0.8
         keepdir[1] = 0.1 + randflt() * 0.8
         keepdir[2] = 0.1 + randflt() * 0.8
         keepdir[3] = keepdir[0]
         keepdir[4] = keepdir[1]
         keepdir[5] = keepdir[2]         
+
+        cubeCount = 0
     }
     
     func clear(color:NSColor = NSColor.blackColor())

                if      (pos.y < 2)        { pos.y = size.y-1 }
                else if (pos.y > size.y-1) { pos.y = 2 }
            }
            skip = -1
            lastPos = randint(5)
        }



        nextPos = (randflt() < keepdir[lastPos]) ? lastPos : randint(5)
        lastPos = nextPos
        
        let side:Side = Side(rawValue:nextPos)!
        switch side
        {
        case .UP:
                pos.y += 1
            
        case .RIGHT:
                if (pos.x%2)==1 { pos.y -= 1 }
                pos.x += 1

        case .LEFT:
                if (pos.x%2)==1 { pos.y -= 1 }
                pos.x -= 1

        case .DOWN:
                pos.y -= 1
                if cubeCount > 0 { skip = .UP }

        case .BACKL:
                if (pos.x%2)==0 { pos.y += 1 }
                pos.x -= 1
                if cubeCount > 0 { skip = .RIGHT }

        case .BACKR:
                if (pos.x%2)==0 { pos.y += 1 }
                pos.x += 1
                if cubeCount > 0 { skip = .LEFT }
            
        default:
                break
