Enhanced dependency resolving

I understand why dark was so upset about the code now.