Refactor dependency resolving