     
     _.extend(this, new EventMixin())
 
-    data = @model.user
+    @user = @model.user
     # create GUI
     modelRadius = @model.route.getActiveNodeRadius()
     @qualityArray = ["high", "medium", "low"]
 
     @datasetPostfix = _.last(@model.binary.dataSetName.split("_"))
-    @datasetPosition = @initDatasetPosition(data.briConNames)
+    @datasetPosition = @initDatasetPosition(@user.briConNames)
 
     somaClickingAllowed = settings.somaClickingAllowed
     
     @settings = 
 
-      rotateValue : data.rotateValue
-      moveValue3d : data.moveValue3d
-      mouseRotateValue : data.mouseRotateValue
-      crosshairSize : data.crosshairSize
+      rotateValue : @user.rotateValue
+      moveValue3d : @user.moveValue3d
+      mouseRotateValue : @user.mouseRotateValue
+      crosshairSize : @user.crosshairSize
       
-      lockZoom : data.lockZoom
-      inverseX : data.inverseX
-      inverseY : data.inverseY
-      dynamicSpaceDirection : data.dynamicSpaceDirection
-
-      moveValue : data.moveValue
-      routeClippingDistance : data.routeClippingDistance
-      displayCrosshairs : data.displayCrosshair
-
-      fourBit : data.fourBit
-      briConNames : data.briConNames
-      brightness : data.brightness[@datasetPosition]
-      contrast : data.contrast[@datasetPosition]
+      lockZoom : @user.lockZoom
+      inverseX : @user.inverseX
+      inverseY : @user.inverseY
+      dynamicSpaceDirection : @user.dynamicSpaceDirection
+
+      moveValue : @user.moveValue
+      routeClippingDistance : @user.routeClippingDistance
+      displayCrosshair : @user.displayCrosshair
+
+      fourBit : @user.fourBit
+      briConNames : @user.briConNames
+      brightness : @user.brightness[@datasetPosition]
+      contrast : @user.contrast[@datasetPosition]
       resetBrightnessAndContrast : => @resetBrightnessAndContrast()
-      interpolation : data.interpolation
-      quality : @qualityArray[data.quality]
-
-      displayPrevXY : data.displayPreviewXY
-      displayPrevYZ : data.displayPreviewYZ
-      displayPrevXZ : data.displayPreviewXZ
-      nodesAsSpheres : data.nodesAsSpheres
+      interpolation : @user.interpolation
+      quality : @qualityArray[@user.quality]
+
+      displayPrevXY : @user.displayPreviewXY
+      displayPrevYZ : @user.displayPreviewYZ
+      displayPrevXZ : @user.displayPreviewXZ
+      nodesAsSpheres : @user.nodesAsSpheres
 
       activeTreeID : @model.route.getActiveTreeId()
       newTree : => @trigger "createNewTree"
       deleteActiveTree : => @trigger "deleteActiveTree"
 
       activeNodeID : @model.route.getActiveNodeId()
-      newNodeNewTree : if somaClickingAllowed then data.newNodeNewTree else false
+      newNodeNewTree : if somaClickingAllowed then @user.newNodeNewTree else false
       deleteActiveNode : => @trigger "deleteActiveNode"
       radius : if modelRadius then modelRadius else 10 * @model.scaleInfo.baseVoxel
       comment : ""

    container.append @gui.domElement
    
    fControls = @gui.addFolder("Controls")
    (fControls.add @settings, "lockZoom")
                          .name("Lock Zoom")
                          .onChange((v) => @setBoolean("lockZoom", v))
    (fControls.add @settings, "inverseX")
                          .name("Inverse X")
                          .onChange((v) => @setBoolean("inverseX", v))
    (fControls.add @settings, "inverseY")
                          .name("Inverse Y")
                          .onChange((v) => @setBoolean("inverseY", v))
    (fControls.add @settings, "dynamicSpaceDirection")
                          .name("d/f-Switching")
                          .onChange((v) => @setBoolean("dynamicSpaceDirection", v))

    fFlightcontrols = @gui.addFolder("Flighcontrols")
    (fFlightcontrols.add @settings, "mouseRotateValue", 0.001, 0.02)
                          .step(0.001)
                          .name("Mouse Rotation")
                          .onChange((v) => @setNumber("mouseRotateValue", v))
    (fFlightcontrols.add @settings, "rotateValue", 0.001, 0.08)
                          .step(0.001)
                          .name("Keyboard Rotation Value")
                          .onChange((v) => @setNumber("rotateValue", v))
    (fFlightcontrols.add @settings, "moveValue3d", 0.1, 10) 
                          .step(0.1)
                          .name("Move Value")    
                          .onChange((v) => @setNumber("moveValue3d", v))
    (fFlightcontrols.add @settings, "crosshairSize", 0.1, 1) 
                          .step(0.01)
                          .name("Crosshair size")    
                          .onChange((v) => @setNumber("crosshairSize", v))                          


    fView = @gui.addFolder("Planes")
    (fView.add @settings, "moveValue", 0.1, 10) 
                          .step(0.1)
                          .name("Move Value")    
                          .onChange((v) => @setNumber("moveValue", v))
    scale = @model.scaleInfo.baseVoxel
    (fView.add @settings, "routeClippingDistance", 1, 1000 * scale)
                          .name("Clipping Distance")    
                          .onChange((v) => @setNumber("routeClippingDistance", v))
    (fView.add @settings, "displayCrosshairs")
                          .name("Show Crosshairs")
                          .onChange((v) => @setBoolean("displayCrosshair", v))

    fView = @gui.addFolder("Voxel")
    (fView.add @settings, "fourBit")
                          .name("4 Bit")
                          .onChange((v) => @setBoolean("fourBit", v))
    @brightnessController =
    (fView.add @settings, "brightness", -256, 256) 
                          .step(5)
                          .name("Brightness")    
                          .onChange( => @setBrightnessAndContrast())
    @contrastController =
    (fView.add @settings, "contrast", 0.5, 5) 
                          .step(0.1)
                          .name("Contrast")    
                          .onChange( => @setBrightnessAndContrast())
    (fView.add @settings, "resetBrightnessAndContrast")
                          .name("Reset To Default")
    (fView.add @settings, "interpolation")
                          .name("Interpolation")
                          .onChange((v) => @setBoolean("interpolation", v))
    (fView.add @settings, "quality", @qualityArray)
                          .name("Quality")
                          .onChange((v) => @setQuality(v))

    fSkeleton = @gui.addFolder("Skeleton View")
    (fSkeleton.add @settings, "displayPrevXY")
                          .name("Display XY-Plane")
                          .onChange((v) => @setBoolean("displayPreviewXY", v))
    (fSkeleton.add @settings, "displayPrevYZ")
                          .name("Display YZ-Plane")
                          .onChange((v) => @setBoolean("displayPreviewYZ", v))
    (fSkeleton.add @settings, "displayPrevXZ")
                          .name("Display XZ-Plane")
                          .onChange((v) => @setBoolean("displayPreviewXZ", v))

    fTrees = @gui.addFolder("Trees")
    @activeTreeIdController =
    (fTrees.add @settings, "activeTreeID")
                          .min(1)
                          .step(1)
                          .name("Active Tree ID")
                          .onFinishChange( (value) => @trigger "setActiveTree", value)
    if somaClickingAllowed
      (fTrees.add @settings, "newNodeNewTree")
                            .name("Soma clicking mode")
                            .onChange((v) => @setBoolean("newNodeNewTree", v))
    else
      @setNewNodeNewTree(false)
    (fTrees.add @settings, "newTree")
                          .name("Create New Tree")
    (fTrees.add @settings, "deleteActiveTree")
                          .name("Delete Active Tree")

    fNodes = @gui.addFolder("Nodes")
    @activeNodeIdController =
    (fNodes.add @settings, "activeNodeID")
                          .min(1)
                          .step(1)
                          .name("Active Node ID")
                          .onFinishChange( (value) => @trigger "setActiveNode", value)
    @commentController =
    (fNodes.add @settings, "comment")
                          .name("Comment")
                          .onChange(@setComment)
    (fNodes.add @settings, "prevComment")
                          .name("Previous Comment")
    (fNodes.add @settings, "nextComment")
                          .name("Next Comment")
    (fNodes.add @settings, "deleteActiveNode")
                          .name("Delete Active Node")

    #fControls.open()
    #fView.open()

      @model.user.briConNames.push(@datasetPostfix)
      @model.user.brightness.push(@settings.brightness)
      @model.user.contrast.push(@settings.contrast)
      @dataSetPosition = @user.briConNames.length - 1


    @gui = new dat.GUI(autoPlace: false, width : 280, hideable : false, closed : true)
