Add json output and redir_retain option