Bug fixes to run_function so that infiles and outfiles can be None