Factored out procedures, loader, and script runner.