                 modelDf.promise.then(incrementC3mlCount)
 
                 if typeName
-                  getOrCreateTypologyByName(typeName).then Meteor.bindEnvironment (typeId) ->
+                  typeArgs =
+                    typePromiseMap: typePromiseMap
+                    projectId: projectId
+                    usedColors: usedColors
+                  typeSuccess = Meteor.bindEnvironment (typeId) ->
                     createEntityArgs.typeId = typeId
                     createEntity()
+                  @getOrCreateTypologyByName(typeName, typeArgs).then(typeSuccess, createEntity)
                 else
                   createEntity()
               

    
    modelDf.promise

  _mapEntity: (doc) -> doc
  _mapTypology: (doc) -> doc
  _mapGeometry: (geom) -> geom

      # A map of parent IDs to a map of children names to their IDs.
      childrenNameMap = {}

      Logger.info('Inserting ' + c3mls.length + ' c3mls...')

      insertedCount = 0
