Make redirection more robust