Fix bug with setting terminal.