pat: added redirection and logging.