Fix up a few bugs,and add a tty cursor.