diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+0.1.0.24
+--------
+* Make obfuscation flush upper bound configurable in `config.json`
+* Fix an IPv6 name resolution bug in remote
+
 0.1.0.23
 ---------
 * Fix a bug to prevent a half closed connection to hold a file handle
diff --git a/moesocks.cabal b/moesocks.cabal
--- a/moesocks.cabal
+++ b/moesocks.cabal
@@ -1,6 +1,6 @@
 name:               moesocks
 category:           Network
-version:            0.1.0.23
+version:            0.1.0.24
 license:            Apache-2.0
 synopsis:           A functional firewall killer
 description:        A socks5 proxy using the client / server architecture.
diff --git a/src/Network/MoeSocks/Common.hs b/src/Network/MoeSocks/Common.hs
--- a/src/Network/MoeSocks/Common.hs
+++ b/src/Network/MoeSocks/Common.hs
@@ -33,6 +33,11 @@
                 <> ":"
                 <> show (_r ^. portNumber)
 
+addressType_To_Family :: AddressType -> Maybe Family
+addressType_To_Family (IPv4_address _) = Just AF_INET
+addressType_To_Family (IPv6_address _) = Just AF_INET6
+addressType_To_Family _                = Nothing
+
 initTarget :: ClientRequest -> IO (Socket, SockAddr)
 initTarget _clientRequest = do
   let 
@@ -47,6 +52,7 @@
 
       _hostName = _clientRequest ^. addressType . to showAddressType
       _port = _clientRequest ^. portNumber
+      _family = _clientRequest ^. addressType . to addressType_To_Family
 
   
-  getSocket _hostName _port _socketType
+  getSocketWithHint _family _hostName _port _socketType
diff --git a/src/Network/MoeSocks/Config.hs b/src/Network/MoeSocks/Config.hs
--- a/src/Network/MoeSocks/Config.hs
+++ b/src/Network/MoeSocks/Config.hs
@@ -18,6 +18,7 @@
   , _tcpBufferSize = 256
   , _throttle = False
   , _throttleSpeed = 8000 -- in Kilobytes
+  , _obfuscationFlushBound = 4096
   }
 
 
diff --git a/src/Network/MoeSocks/Helper.hs b/src/Network/MoeSocks/Helper.hs
--- a/src/Network/MoeSocks/Helper.hs
+++ b/src/Network/MoeSocks/Helper.hs
@@ -197,7 +197,12 @@
 
 getSocket :: (Integral i, Show i) => Text -> i -> SocketType ->
                                       IO (Socket, SockAddr)
-getSocket aHost aPort aSocketType = do
+getSocket = getSocketWithHint Nothing
+
+getSocketWithHint :: (Integral i, Show i) => 
+                        Maybe Family -> Text -> i -> SocketType -> 
+                        IO (Socket, SockAddr)
+getSocketWithHint maybeFamily aHost aPort aSocketType = do
     {-puts - "getSocket: " <> show aHost <> ":" <> show aPort-}
 
     maybeAddrInfo <- firstOf folded <$>
@@ -227,10 +232,11 @@
           pure (_socket, address)
           
   where
+    _family = maybeFamily & fromMaybe AF_INET
     hints = defaultHints {
               addrFlags = [AI_ADDRCONFIG, AI_NUMERICSERV]
             , addrSocketType = aSocketType
-            , addrFamily = AF_INET
+            , addrFamily = _family
             }
 
 builder_To_ByteString :: B.Builder -> ByteString
@@ -260,20 +266,18 @@
 send_ :: Socket -> ByteString -> IO ()
 send_ = sendAll
 
-sendAllRandom :: Socket -> ByteString -> IO ()
-sendAllRandom aSocket aBuffer = do
-  -- _lengthUpperBound <- randomRIO (1024, 4096)
-  _lengthUpperBound <- pure 2048
-  _loop _lengthUpperBound aBuffer
+sendAllRandom :: Int -> Socket -> ByteString -> IO ()
+sendAllRandom aFlushBound aSocket aBuffer = do
+  _loop aBuffer
   where
-    _loop _bound _buffer = do
-      _randomLength <- randomRIO (0, _bound)
+    _loop _buffer = do
+      _randomLength <- randomRIO (0, aFlushBound)
       {-_say - "randomLength: " <> show _randomLength-}
       let (_thisBuffer, _nextBuffer) = S.splitAt _randomLength _buffer
       sendAll aSocket _thisBuffer
       when (_nextBuffer & isn't _Empty) - do
         yield
-        _loop _bound _nextBuffer
+        _loop _nextBuffer
 
 sendBytes :: HQueue -> ByteString -> IO ()
 sendBytes _queue = atomically . writeTBQueue _queue . S.Just
@@ -373,8 +377,8 @@
   
 
 consumeLoop :: String -> Timeout -> Maybe Double ->
-                Socket -> HQueue -> Bool -> IO ()
-consumeLoop aID aTimeout aThrottle aSocket aTBQueue randomize = do
+                Socket -> HQueue -> Bool -> Int -> IO ()
+consumeLoop aID aTimeout aThrottle aSocket aTBQueue randomize aBound = do
   _startTime <- getCurrentTime
   
   
@@ -411,7 +415,7 @@
           S.Nothing -> () <$ _shutdown
           S.Just _data -> do
                           let _send = if randomize 
-                                          then sendAllRandom
+                                          then sendAllRandom aBound
                                           else sendAll
                                                     
                           timeoutFor aID aTimeout - 
diff --git a/src/Network/MoeSocks/TCP.hs b/src/Network/MoeSocks/TCP.hs
--- a/src/Network/MoeSocks/TCP.hs
+++ b/src/Network/MoeSocks/TCP.hs
@@ -75,6 +75,7 @@
       _c = aEnv ^. config 
       _cipherBox = aEnv ^. cipherBox
       _obfuscation = aEnv ^. options . obfuscation
+      _flushBound = _c ^. obfuscationFlushBound
 
       _initSocket = 
           getSocket (_c ^. remote) (_c ^. remotePort) Stream 
@@ -98,15 +99,15 @@
     
     _log - "L T: " <> _msg
 
-    let handleLocal __remoteSocket = do
+    let handleLocal _remoteSocket = do
           _encodeIV <- _cipherBox ^. generateIV 
           _encrypt <- _cipherBox ^. encryptBuilder - _encodeIV
           
           let 
               _header = shadowSocksRequestBuilder _clientRequest
           
-          sendChannel <- newTBQueueIO - _c ^. tcpBufferSize
-          receiveChannel <- newTBQueueIO - _c ^. tcpBufferSize
+          _sendChannel <- newTBQueueIO - _c ^. tcpBufferSize
+          _receiveChannel <- newTBQueueIO - _c ^. tcpBufferSize
 
           let _logId x = x <> " " <> _msg
               _timeout = _c ^. timeout * 1000 * 1000
@@ -116,11 +117,11 @@
                   else Nothing
 
           let sendThread = do
-                sendBytes sendChannel _encodeIV
-                sendBuilderEncrypt sendChannel _encrypt _header
+                sendBytes _sendChannel _encodeIV
+                sendBuilderEncrypt _sendChannel _encrypt _header
 
                 when (_partialBytesAfterClientRequest & isn't _Empty) -
-                  sendBytesEncrypt sendChannel _encrypt 
+                  sendBytesEncrypt _sendChannel _encrypt 
                     _partialBytesAfterClientRequest
 
                 let _produce = do
@@ -128,16 +129,17 @@
                                     _timeout
                                     _NoThrottle
                                     aSocket 
-                                    sendChannel 
+                                    _sendChannel 
                                     _encrypt
 
                 let _consume = do
                                   consumeLoop (_logId "L --> - Loop")
                                     _timeout
                                     _throttle
-                                    __remoteSocket 
-                                    sendChannel
+                                    _remoteSocket 
+                                    _sendChannel
                                     _obfuscation
+                                    _flushBound
                 finally
                   (
                     connectMarket (Just - _logId "L --> +", _produce)
@@ -146,14 +148,14 @@
                   pure ()
 
           let receiveThread = do
-                _decodeIV <- recv __remoteSocket (_cipherBox ^. ivLength)
+                _decodeIV <- recv _remoteSocket (_cipherBox ^. ivLength)
                 _decrypt <- _cipherBox ^. decryptBuilder - _decodeIV
 
                 let _produce = produceLoop (_logId "L <-- + Loop")
                                   _timeout
                                   _NoThrottle
-                                  __remoteSocket 
-                                  receiveChannel
+                                  _remoteSocket 
+                                  _receiveChannel
                                   _decrypt
 
                 let _consume = do
@@ -161,8 +163,9 @@
                                     _timeout
                                     _NoThrottle
                                     aSocket 
-                                    receiveChannel
+                                    _receiveChannel
                                     False
+                                    _flushBound
                 finally 
                   (
                     connectMarket (Just - _logId "L <-- +", _produce)
@@ -184,6 +187,7 @@
         _obfuscation = aEnv ^. options . obfuscation
         _cipherBox = aEnv ^. cipherBox
         _c = aEnv ^. config
+        _flushBound = _c ^. obfuscationFlushBound
 
   _decodeIV <- recv aSocket (_cipherBox ^. ivLength)
   _decrypt <- _cipherBox ^. decryptBuilder - _decodeIV
@@ -212,9 +216,9 @@
     _log - "R T: " <> _msg
 
     let 
-        handleTarget __leftOverBytes __targetSocket = do
-          sendChannel <- newTBQueueIO - _c ^. tcpBufferSize
-          receiveChannel <- newTBQueueIO - _c ^. tcpBufferSize
+        handleTarget _leftOverBytes __targetSocket = do
+          _sendChannel <- newTBQueueIO - _c ^. tcpBufferSize
+          _receiveChannel <- newTBQueueIO - _c ^. tcpBufferSize
 
           let _logId x = x <> " " <> _msg
               -- let remote wait slightly longer, so local can timeout
@@ -228,22 +232,23 @@
 
           let sendThread = do
                 when (_leftOverBytes & isn't _Empty) -
-                  atomically - writeTBQueue sendChannel - S.Just _leftOverBytes
+                  atomically - writeTBQueue _sendChannel - S.Just _leftOverBytes
 
                 let _produce = do
                                   produceLoop (_logId "R --> + Loop")
                                     _timeout
                                     _NoThrottle 
                                     aSocket
-                                    sendChannel
+                                    _sendChannel
                                     _decrypt
 
                 let _consume = consumeLoop (_logId "R --> - Loop")
                                   _timeout
                                   _NoThrottle
-                                  __targetSocket
-                                  sendChannel
+                                  _targetSocket
+                                  _sendChannel
                                   False
+                                  _flushBound
 
                 finally
                   (
@@ -255,14 +260,14 @@
           let receiveThread = do
                 _encodeIV <- _cipherBox ^. generateIV 
                 _encrypt <- _cipherBox ^. encryptBuilder - _encodeIV
-                sendBytes receiveChannel _encodeIV
+                sendBytes _receiveChannel _encodeIV
 
                 let _produce = do
                                   produceLoop (_logId "R <-- + Loop")
                                     _timeout
                                     _NoThrottle 
-                                    __targetSocket
-                                    receiveChannel
+                                    _targetSocket
+                                    _receiveChannel
                                     _encrypt
 
 
@@ -271,8 +276,9 @@
                                     _timeout
                                     _throttle
                                     aSocket
-                                    receiveChannel
+                                    _receiveChannel
                                     _obfuscation
+                                    _flushBound
 
                 finally 
                   (
diff --git a/src/Network/MoeSocks/Type.hs b/src/Network/MoeSocks/Type.hs
--- a/src/Network/MoeSocks/Type.hs
+++ b/src/Network/MoeSocks/Type.hs
@@ -3,7 +3,6 @@
 
 module Network.MoeSocks.Type where
 
-import Control.Concurrent.STM
 import Control.Lens
 import Control.Monad.Except
 import Control.Monad.Reader
@@ -60,6 +59,7 @@
   , _tcpBufferSize :: Int -- in packets
   , _throttle :: Bool
   , _throttleSpeed :: Double
+  , _obfuscationFlushBound :: Int -- should be greater then MTU
   }
   deriving (Show, Eq, Generic)
 
@@ -125,8 +125,5 @@
 makeLenses ''Env
 
 
-
-
-type Queue = TBQueue (Maybe ByteString) 
 type MoeMonadT = ReaderT MoeOptions (ExceptT String IO)
 
