Fixed bugs related to scanner.