Scripts cleanup and refactoring.