Windows TTY fixes

@sblom Could you review this please?