diff --git a/NEWS b/NEWS
index 5e2452f1c87a06cf65e44f07fb16e500fc22954a_TkVXUw==..45eebb7ea9ae3ef69b3fbf1e49136efeb2253f40_TkVXUw== 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,20 @@
 Releases
 ========
 
+v1.11.4 (21st Jan 2014)
+-----------------------
+
+* #193 (and its attentant PRs #230 & #253): Fix SSH agent problems present on
+  Windows. Thanks to David Hobbs for initial report and to Aarni Koskela & Olle
+  Lundberg for the patches.
+
+v1.10.6 (21st Jan 2014)
+-----------------------
+
+* #193 (and its attentant PRs #230 & #253): Fix SSH agent problems present on
+  Windows. Thanks to David Hobbs for initial report and to Aarni Koskela & Olle
+  Lundberg for the patches.
+
 v1.11.3 (8th Jan 2014)
 ----------------------
 
diff --git a/paramiko/_winapi.py b/paramiko/_winapi.py
index 5e2452f1c87a06cf65e44f07fb16e500fc22954a_cGFyYW1pa28vX3dpbmFwaS5weQ==..45eebb7ea9ae3ef69b3fbf1e49136efeb2253f40_cGFyYW1pa28vX3dpbmFwaS5weQ== 100644
--- a/paramiko/_winapi.py
+++ b/paramiko/_winapi.py
@@ -10,6 +10,11 @@
 import ctypes.wintypes
 import __builtin__
 
+try:
+        USHORT = ctypes.wintypes.USHORT
+except AttributeError:
+        USHORT = ctypes.c_ushort
+
 ######################
 # jaraco.windows.error
 
@@ -81,9 +86,6 @@
 		raise WindowsError()
 
 
-#####################
-# jaraco.windows.mmap
-
 CreateFileMapping = ctypes.windll.kernel32.CreateFileMappingW
 CreateFileMapping.argtypes = [
 	ctypes.wintypes.HANDLE,
@@ -130,11 +132,14 @@
 		self.pos = pos
 
 	def write(self, msg):
-		ctypes.windll.msvcrt.memcpy(self.view + self.pos, msg, len(msg))
-		self.pos += len(msg)
+		n = len(msg)
+		if self.pos + n >= self.length:  # A little safety.
+			raise ValueError("Refusing to write %d bytes" % n)
+		ctypes.windll.kernel32.RtlMoveMemory(self.view + self.pos, msg, n)
+		self.pos += n
 
 	def read(self, n):
 		"""
 		Read n bytes from mapped view.
 		"""
 		out = ctypes.create_string_buffer(n)
@@ -135,10 +140,10 @@
 
 	def read(self, n):
 		"""
 		Read n bytes from mapped view.
 		"""
 		out = ctypes.create_string_buffer(n)
-		ctypes.windll.msvcrt.memcpy(out, self.view + self.pos, n)
+		ctypes.windll.kernel32.RtlMoveMemory(out, self.view + self.pos, n)
 		self.pos += n
 		return out.raw
 
@@ -173,7 +178,7 @@
 		PACL Dacl;
 		}   SECURITY_DESCRIPTOR;
 	"""
-	SECURITY_DESCRIPTOR_CONTROL = ctypes.wintypes.USHORT
+	SECURITY_DESCRIPTOR_CONTROL = USHORT
 	REVISION = 1
 
 	_fields_ = [
diff --git a/paramiko/win_pageant.py b/paramiko/win_pageant.py
index 5e2452f1c87a06cf65e44f07fb16e500fc22954a_cGFyYW1pa28vd2luX3BhZ2VhbnQucHk=..45eebb7ea9ae3ef69b3fbf1e49136efeb2253f40_cGFyYW1pa28vd2luX3BhZ2VhbnQucHk= 100644
--- a/paramiko/win_pageant.py
+++ b/paramiko/win_pageant.py
@@ -23,4 +23,7 @@
 
 from __future__ import with_statement
 
+import array
+import ctypes.wintypes
+import platform
 import struct
@@ -26,8 +29,9 @@
 import struct
-import threading
-import array
-import platform
-import ctypes.wintypes
+
+try:
+    import _thread as thread # Python 3.x
+except ImportError:
+    import thread # Python 2.5-2.7
 
 from . import _winapi
 
@@ -31,6 +35,7 @@
 
 from . import _winapi
 
+
 _AGENT_COPYDATA_ID = 0x804e50ba
 _AGENT_MAX_MSGLEN = 8192
 # Note: The WM_COPYDATA value is pulled from win32con, as a workaround
@@ -51,4 +56,5 @@
     """
     return bool(_get_pageant_window_object())
 
+
 ULONG_PTR = ctypes.c_uint64 if platform.architecture()[0] == '64bit' else ctypes.c_uint32
@@ -54,4 +60,6 @@
 ULONG_PTR = ctypes.c_uint64 if platform.architecture()[0] == '64bit' else ctypes.c_uint32
+
+
 class COPYDATASTRUCT(ctypes.Structure):
     """
     ctypes implementation of
@@ -61,7 +69,8 @@
         ('num_data', ULONG_PTR),
         ('data_size', ctypes.wintypes.DWORD),
         ('data_loc', ctypes.c_void_p),
-        ]
+    ]
+
 
 def _query_pageant(msg):
     """
@@ -74,7 +83,7 @@
         return None
 
     # create a name for the mmap
-    map_name = 'PageantRequest%08x' % threading.current_thread().ident
+    map_name = 'PageantRequest%08x' % thread.get_ident()
 
     pymap = _winapi.MemoryMap(map_name, _AGENT_MAX_MSGLEN,
         _winapi.get_security_attributes_for_user(),
@@ -98,7 +107,8 @@
             return datalen + pymap.read(retlen)
         return None
 
-class PageantConnection (object):
+
+class PageantConnection(object):
     """
     Mock "connection" to an agent which roughly approximates the behavior of
     a unix local-domain socket (as used by Agent).  Requests are sent to the