various fixes in the type system.
merged