Move more implementation to termios