Removed embedded scripts. Added proper error reporting to main script run