fixed token parsing
Added a bunch of sanity checks, and a method for creating the initial tables