fixes for PTY handling