Visual artifact fix.

On some terminal emulators, visual artifacts appeared on the screen
under some circumstances.  This is a first attempt to fix that bug;
more testing is necessary.