Make generation of dependency files more efficient when possible