Miscellaneous changes.

Changed AST representation, the error reporting and some typing stuff.