Script developments/improvments

Any suggestion or solution for any issues what they make a good more flexibility and effective code and structure.