 
 : deactivate-model ( model -- )
     dup unref-model zero? [
-        dup model-dependencies
+        dup dependencies>>
         [ dup deactivate-model remove-connection ] with each
     ] [
         drop

M: model model-activated drop ;

: ref-model ( model -- n )
    dup model-ref 1+ dup rot set-model-ref ;

: unref-model ( model -- n )
    dup model-ref 1- dup rot set-model-ref ;

: activate-model ( model -- )
    dup ref-model 1 = [
        dup model-dependencies
        [ dup activate-model dupd add-connection ] each
        model-activated
    ] [

M: model hashcode* drop model hashcode* ;

: add-dependency ( dep model -- )
    dependencies>> push ;

: remove-dependency ( dep model -- )
    dependencies>> delete ;

DEFER: add-connection

