Added improved error handling to shell scripts.