Rearrange some script structure.