Improve dependency handling