Refactoring and cleanup to import-based script execution.