Script startup refactoring