Enhancements to pkgmgr (extract method) and better handling of environmnent in process.sudo_run_program