Added meaningful error messages and logging. Fixed bash script file