Added debug messages to scan code.