                 let group = LevelGroup(levels: [audioLevel])
                 groups.append(group)
             }
-            optimumWidth = totalLevels
+            canvasWidth = CGFloat(totalLevels)
         } else {
-            optimumWidth = Int(bounds.size.width)
-            while (totalLevels % optimumWidth == 0) {
-                --optimumWidth
-            }
-            
-            let levelsInAGroup = totalLevels / optimumWidth
+            canvasWidth = bounds.size.width
+            while (totalLevels % Int(canvasWidth) == 0) {
+                --canvasWidth
+            }
+            
+            let levelsInAGroup = totalLevels / Int(canvasWidth)
             var currentGroup: LevelGroup
             var levelsForCurrentGroup: Float[] = []
             

class EditorView: NSView {
    
    // MARK: Defined types
    struct LevelGroup {
        let levels: Float[]
        var average: Float {

            return height
        }
        
        var startPointX = firstBandX
        let currentContext: CGContextRef = Unmanaged<CGContext>.fromOpaque(NSGraphicsContext.currentContext().graphicsPort()).takeUnretainedValue()
        
        CGContextSetLineWidth(currentContext, 1.0)
