Bug fixes for the scanner.