Added error logging to script.
Fixed syntax errors in the script.