Refactor output buffering to give all commands access to stdout and stderr