build: improve dependency handling