Many robustness improvements in do-collect.sh script.