Introduce maxRedirect, close #1361