fix save script and data dialog; and refactor