Minor refactor

* Lexer to read from buffer instead of readfile() in an attempt to pick
  up unsaved changes as well.
* Other minor refactors
Fixed lexer