minor fixes, working on the scan algorithm