Analized a part of the solution for the "Save as new" feature
Created a method, "_prepare_script()", which saves a few of repeated lines.