Improve dependency resolve logic so that multiple nested dependencies
are resolved correctly.