Refactor all scripts