fix scripts to use less memory, and when generating trigger, break the long lines