[typesystem] refactoring