After I move resolveListOfK beyond FlattenTerms step. Every works magically.