Various fixes and adds, implementing the AST and its semantics checks.
Fixes #29, fixes #30.