Improvements to run_command, see commit messages