IOB:  Fix errors in trimming logic