Type system, not yet complete.
Added meaningful exception types.
Some fixes for the type system, should be quite usable now.