Fixed some lexing issues that were causing unicode errors and misc. bugs.

I improved the lexer and made it easier to understand and less error-prone. I removed a line that forced an encoding and caused errors on unicode input. I updated some related scripts. Updated the "type" attribute of ParseTreeNodes to be "nodetype" so as not to conflict with the built-in type function. 

Closes #122 
Closes #124