[Refactoring] Fix possible exception while batch fixing bugs.