Cleanup logging

Made minor changes to logging and refactored the scan logic to
reduce duplicate code (and duplicate log lines).