Clean up handle_redirect.