some fixes with write to tun device