Changed: separate handling of script errors and script termination