         if newName in names
           JsPath.setAt def, path.concat(names.indexOf newName), newModel
 
-  listModels=(root="", modelPath, acc={})->
-    path = nodePath.join root, modelPath
-    stat = fs.statSync path
-    if stat.isDirectory()
-      names = fs.readdirSync path
-      for name in names
-        listModels root, nodePath.join(modelPath, name), acc
-    else if /(\.coffee|\.js)$/.test path
-      acc[path] = NOTREADY
-    return acc
-
-  createModelRegistry:(modelPath)->
-    acc = {}
-    if Array.isArray modelPath
-      listModels @root, item, acc  for item in modelPath
+  findCode = (paths) ->
+    Promise.map paths, (path) ->
+      fs.statAsync(path).then (stats) ->
+        # in the case that this is a directory, recurse into it
+        if stats.isDirectory()
+          fs.readdirAsync(path).map (dir) ->
+            nodePath.join path, dir
+          .then findCode
+        # otherwise, just collect the path
+        else path
+    # only consider .js and .coffee files as "code"
+    .filter (path) ->
+      /(\.coffee|\.js)$/.test path
+    # flatten the result
+    .reduce (a, b) ->
+      a.concat b
+    , []
+
+  registerModel: (cons) ->
+    if cons.name? and ('function' is typeof cons)
+      @defineModel cons.name, cons
     else
-      listModels @root, modelPath, acc
-    new ModelRegistry acc
-
-  loadModels: (modelPath) ->
-    @registry = @createModelRegistry(modelPath)
-    @registry.forEach (path) =>
-      try model = require path
-      catch e
-        console.error e
-        err = new Error
-        err.originalError = e
-        err.message = "Error loading a class: #{path}"
-        return @emit 'error', err
-      if model.name? and ('function' is typeof model)
-        @defineModel model.name, model
-      else
-        @defineModel name, konstructor  for own name, konstructor of model
-      @registry.setState path, READY
-    @emit 'ready'
+      @defineModel name, konstructor  for own name, konstructor of cons
+
+  loadConstructors: (consPaths) ->
+    consPaths = [consPaths]  unless Array.isArray consPaths
+
+    paths = consPaths.map (path) =>
+      nodePath.join @root, path
+
+    findCode(paths).map (codePath) =>
+      @registerModel require codePath
+
+    .catch (err) ->
+      throw new Error "Error loading a class: #{ err.message }"
 
   getInstanceRoutingKey =(inst, event)->
     "oid.#{inst.getId()}.event.#{event}"


module.exports = class Bongo extends EventEmitter
  [READY, NOTREADY] = [0,1]
  # core
  url = require 'url'
  fs = require 'fs'
  nodePath = require 'path'

  require 'colors'

  {extend}        = require 'underscore'
  @JsPath = JsPath = require 'jspath'
  @Inflector      = require 'inflector'

  # lib
  # the base klass of the library:
  @Base = Base    = require './base'
