Completely rework the dependency handling in the build system