Fix crasher in resizing height.
Refactor how DEC/ANSI modes are set.