Move the majority of scan() functionality into a worker for background processing.