various typesystem bugfixes