Additional rearranging of main script