Slight optimization for the version map gathering

only iterate over the versions once and use `groupBy` to sort the dependencies into the version mapping