Bug fixes to collect.sh