         alert "Inner Process: \n#{innerText}"
         if typeof innerText == "undefined" or innerText == null or innerText == ""
             return
+        while innerText != ""
+            for command of @commands
+                result = @commands[command]['regex'].exec innerText
+                if result != null
+                    @commands[command]['usesRemaining']--
+                    alert "Found: \n#{result[0]}"
+                    @processMatch command, result[1]
+                    break
+
+            if result == null
+                result = /^,/.exec innerText
+
+            if result == null
+                innerText = innerText.substring 1
+            else
+                innerText = innerText.substring result[0].length
+
+        return
+
+    UpdateCommandsStatus: ->
+        ###
+            Updates the number of commands remaining for each command.
+        ###
+        buttonField = jQuery '#insertButtons'
         for command of @commands
-            result = @commands[command]['regex'].exec innerText
-            if result != null
-                @commands[command]['usesRemaining']--
-                alert "Found: \n#{result[0]}"
-                @processMatch command, result[1]
-
-            if result == null
-                result = /^,/.exec innerText
-
-        return
-
-    UpdateCommandsStatus: ->
-        ###
-            Updates the number of commands remaining for each command.
-        ###
-        buttonField = jQuery('#insertButtons')
-        for command of @commands
-            button = buttonField.find("##{command}")
-            line = @createBlankFunctionHeader(command)
+            button = buttonField.find "##{command}"
+            line = @createBlankFunctionHeader command
             usesRemaining = @commands[command]['usesRemaining']
-            button.text("#{line}: #{usesRemaining}")
+            if usesRemaining <= 0
+                button.attr 'disabled', true
+
+            button.text "#{line}: #{usesRemaining}"
         return
 
     switchUp: ({currentRow, currentColumn}) ->


    deleteLine: ({text, currentRow}) ->
        line = text.getLine currentRow
        if line != ""
            command = @getCommandFromLine line
            @commands[command]['usesRemaining']++
            @UpdateCommandsStatus()
        if text.getLength() == 1
            text.insertLines currentRow + 1, ["\n"]
            text.removeNewLine currentRow
        text.removeLines currentRow, currentRow
        return

    getCommandFromLine: (line) ->
        re = /^(.+)\(/
        return re.exec(line)[1]

    insertLine: ({text, line, currentRow}) ->
        command = @getCommandFromLine(line)
        if @commands[command]['usesRemaining'] > 0
            @commands[command]['usesRemaining']--

            inputsDiv = jQuery('#insertButtons')
            text.insertLines currentRow, [line]

            if text.getLength() == 2 and text.getLine(currentRow + 1) == ""
                text.removeNewLine currentRow

            @UpdateCommandsStatus()
        return

    resetState: ->

        ###
            This function is triggered after the text in the ace editor is changed.
        ###
        if @scanTextID
            window.clearTimeout @scanTextID
            delete @scanTextID
        @scanTextID = window.setTimeout @scanTextCallback.bind(@), 1500
        return true

    scanTextCallback: ->
        @scanText()
        @UpdateCommandsStatus()

    scanText: ->
        ###
