Fix bug and tidy

Fix #61174, #58962