Make some fixes to term mode