Fix various template parsing issues, makes tokenizer useable from outside the parser. Closes #169 Closes #173