Fixed dependency resolution algorithm