Improved scanner code

All tokens are finalized