                             else
                                 return 'oneFingerRotateContraClockwise'
         return false
-class MouseAction
-    constructor: (@hand) ->
+    class MouseAction
+        constructor: (@hand) ->
 
-    run: ->
-        if @hand.pinchStrength > 0
-            console.log( 'hand.pinchStrength: ' + @hand.pinchStrength)
-            # do click
+        run: ->
+            if @hand.pinchStrength > 0
+                console.log( 'hand.pinchStrength: ' + @hand.pinchStrength)
+                # do click
 
-class KeyboardAction
-    runKeyCombo: (keyCombo) -> 
-        #press keys
-        for key in keyCombo
-            robot.keyToggle(key, true)
+    class KeyboardAction
+        runKeyCombo: (keyCombo) -> 
+            #press keys
+            for key in keyCombo
+                super
+                robot.keyToggle(key, true)
 
-        #release keys
-        for key in keyCombo by -1
-            robot.keyToggle(key, false)
-
-processFrame = (frame) ->
-    # run if the frame is valid and the controller does not have to wait
-    if frame.valid and !mainController.hasToWait()
-        mainController.setFrame(frame)
-        mainController.run()
-
-# T. The 'new' keyword here caught my attention and got me thinking.. Most of the classes are fundamentally singletons and there's coffeescript syntax available to do exactly that, right? 
-# https://coffeescript-cookbook.github.io/chapters/design_patterns/singleton
-# P. I see no point in using a singleton right now. We have plenty to do.
-keyboard = new KeyboardAction()
-mainController = new MainController()
-loopController.connect()
-loopController.on('frame', processFrame)
+            #release keys
+            for key in keyCombo by -1
+                super
+                robot.keyToggle(key, false)
 
 
-###
-    The Call of Cthulhu!
-    checks if two arrays are equal
-### 
-Array::arrayIsEqual = (o) ->
-    return true if this is o
-    return false if this.length isnt o.length
-    for i in [0..this.length]
-        return false if this[i] isnt o[i]
-    true+#-------------------------------------------------------------
+# Boom
+keyboard = new KeyboardAction()
+frameController = new FrameController()
# Load LeapJS 
`Leap = require('leapjs');` # embed JavaScript code directly in your CoffeeScript so 'Leap' is global

# T. <-- This approach looks like a hack, but I remember doing something similar. Do we really need to include leapjs like this???
# P. it is a hack, but I couldn't find anything else. `sad face`

# Desktop Automation. Control the mouse, keyboard, and read the screen.
robot = require("robotjs")

# Local gesture and actions configs
config = require('.././config.json') # TODO: Use yaml


loopController = new Leap.Controller( 
                        inBrowser:              false, 
                        enableGestures:         true, 
                        frameEventName:         'deviceFrame', 
                        background:             true,
                        loopWhileDisconnected:  false
                    )

class MainController
    constructor: () ->
        @gestureSequence = []
        @extendedFingers = []
        @timeout         = false
        @lastGestureTime = 0
        @wait            = 0
    setFrame: (@frame) -> 

    # This stuff needs structure.
    # - 
    run: ->
        @extendedFingers = @getExtendedFingers()
        # check if in mouse mode
        if @isInMouseMode()
            mouseAction = new MouseAction(@frame.hands[0])
            mouseAction.run()
        else
            gestureController = new Gesture(@frame, @extendedFingers)

            currentGesture = gestureController.detect()
            if currentGesture and currentGesture != @gestureSequence[@gestureSequence.length - 1] 

        now = new Date() 
        return if ((now.getTime() - @lastGestureTime) < @wait) then true else false


# Gesture controller's job is to recieve "leapgim frames" from the frame controller. 
class GestureController

    constructor: (@frame, @extendedFingers) ->
        # Desktop Automation. Control the mouse, keyboard, and read the screen.
        @robot = require("robotjs")

    detect: ->
        if @frame.gestures.length > 0
