Added extra checks to prevent crashes when scripts were not found