Script clean and restructure