Modified the type restriction algorithm.