Fixed readwrite stream, added tun support