IMPORTANT - changed the dependency fetching algorithm (used to go through all dependencies to find the ones in the same group - n^2 in total); now it goes only through the neighboring ones until it can consume)