Implement dependency graph. Closes #2.