bug fixes, cleanup, reworked tokenizer