large refactor of scanner
bugs