       if !--todo
         cb()
 
-    fs.readdir(dir, (err, files)->
+    fs.readdir(dir, (err, files)=>
       if err
         return cb(err)
       todo = files.length
 
-      grammarPath = path.join(dir, file)
-      # CSON.resolve uses fs.isFileSync we'll have to check it in the next step but only on valid files.
-      if CSON.isObjectPath(grammarPath)
-        @_registryLoadGrammar(grammarPath,(err)->
-          done(err)
-        )
+      while files.length
+        file = files.shift()
+        grammarPath = path.join(dir, file)
+        # CSON.resolve uses fs.isFileSync we'll have to check it in the next step but only on valid files.
+        if CSON.isObjectPath(grammarPath)
+          @_registryLoadGrammar(grammarPath,(err)->
+            done(err)
+          )
     )
 
   _registryLoadGrammar:(grammarPath,cb)->
-    fs.stat(grammarPath,(err,stat)->
+    fs.stat(grammarPath,(err,stat)=>
       if err
         return cb(err)
 

    )

  _populateGrammars: (grammarsFromJSON,grammarsArray,cb) ->
    toLoad = grammarsArray.length
    grammars = []

    done = (err,grammar)=>
      if err
        return cb(err)

      grammars.push(grammar)

      if !--toLoad
        # complete loading from grammars.json

      return @_loadingGrammars.push(cb)

    @_loadingGrammars = [cb]
    callbacks = (err) =>
      console.log('LOADGRAMMARS: finished loading. unrolling ',@_loadingGrammars)
      if err
        console.log(err+''+err.stack)

      cbs = @_loadingGrammars
      @_loadingGrammars = true
      while cbs.length
