Type system and error reporting fixes.