Iterate over dependencies.keySet()

Fixing memory leak described in issue #96
Merge pull request #97 from romikk/master

Iterate over dependencies.keySet() in DAGManager