Add functions to support console redirection