Refactoring. Use  one thread per scan block. Removed single-threaded mode.