Reimplemented terminal redraw logic.