Further improvements to collect_packages()