fix a bug that causes ncurses to fail with exception
some improvements