diff --git a/icccm/icccm.c b/icccm/icccm.c
index 52a33ce..ec90746 100644
--- a/icccm/icccm.c
+++ b/icccm/icccm.c
@@ -1,39 +1,49 @@
 #include <stdlib.h>
+/* TODO: proper include? */
+#include <limits.h>
 #include <string.h>
+
 #include "xcb_icccm.h"
 #include "xcb_atom.h"
 
-
-int
+xcb_text_property_cookie_t 
 xcb_get_text_property(xcb_connection_t *c,
-                      xcb_window_t      window,
-                      xcb_atom_t        property,
-                      uint8_t          *format,
-                      xcb_atom_t       *encoding,
-                      uint32_t         *name_len,
-                      char            **name)
+                      xcb_window_t window,
+                      xcb_atom_t property)
 {
-	xcb_get_property_cookie_t cookie;
-	xcb_get_property_reply_t *reply;
+  return xcb_get_any_property(c, 0, window, property, UINT_MAX);
+}
 
-	cookie = xcb_get_any_property(c, 0, window, property, 128);
-	reply = xcb_get_property_reply(c, cookie, 0);
-	if(!reply)
-		return 0;
-	*format = reply->format;
-	*encoding = reply->type;
-	*name_len = xcb_get_property_value_length(reply) * *format / 8;
-	if(reply->bytes_after)
-	{
-		cookie = xcb_get_property(c, 0, window, property, reply->type, 0, *name_len);
-		free(reply);
-		reply = xcb_get_property_reply(c, cookie, 0);
-		if(!reply)
-			return 0;
-	}
-	memmove(reply, xcb_get_property_value(reply), *name_len);
-	*name = (char *) reply;
-	return 1;
+xcb_text_property_cookie_t
+xcb_get_text_property_unchecked(xcb_connection_t *c,
+                                xcb_window_t window,
+                                xcb_atom_t property)
+{
+  /* TODO: no xcb_get_any_property_unchecked, wtf?! */
+  static const xcb_atom_t type = XCB_GET_PROPERTY_TYPE_ANY;
+  return xcb_get_property(c, 0, window, property, type, 0, UINT_MAX);
+}
+
+xcb_text_property_t *
+xcb_get_text_property_reply(xcb_connection_t *c,
+                            xcb_text_property_cookie_t cookie,
+                            xcb_generic_error_t **e)
+{
+  xcb_get_property_reply_t *reply = xcb_get_property_reply(c, cookie, e);
+  xcb_text_property_t *prop;
+
+  if(!reply)
+    return NULL;
+
+  prop = malloc(sizeof(xcb_text_property_t));
+  prop->format = reply->format;
+  prop->encoding = reply->type;
+  prop->name_len = xcb_get_property_value_length(reply) * prop->format / 8;
+  memmove(prop->name, xcb_get_property_value(reply), prop->name_len);
+
+  free(reply);
+
+  return prop;
 }
 
 /* WM_NAME */
@@ -45,7 +55,8 @@ xcb_set_wm_name_checked (xcb_connection_t *c,
                          uint32_t          name_len,
                          const char       *name)
 {
-	xcb_change_property_checked(c, XCB_PROP_MODE_REPLACE, window, WM_NAME, encoding, 8, name_len, name);
+  xcb_change_property_checked(c, XCB_PROP_MODE_REPLACE, window, WM_NAME,
+                              encoding, 8, name_len, name);
 }
 
 void
@@ -58,15 +69,18 @@ xcb_set_wm_name (xcb_connection_t *c,
 	xcb_change_property(c, XCB_PROP_MODE_REPLACE, window, WM_NAME, encoding, 8, name_len, name);
 }
 
-int
-xcb_get_wm_name (xcb_connection_t *c,
-                 xcb_window_t      window,
-                 uint8_t          *format,
-                 xcb_atom_t       *encoding,
-                 uint32_t         *name_len,
-                 char            **name)
+xcb_text_property_cookie_t
+xcb_get_wm_name(xcb_connection_t *c,
+                xcb_window_t window)
 {
-	return xcb_get_text_property(c, window, WM_NAME, format, encoding, name_len, name);
+  return xcb_get_text_property(c, window, WM_NAME);
+}
+
+xcb_text_property_cookie_t
+xcb_get_wm_name_unchecked(xcb_connection_t *c,
+                          xcb_window_t window)
+{
+  return xcb_get_text_property_unchecked(c, window, WM_NAME);
 }
 
 void
@@ -100,15 +114,11 @@ xcb_set_wm_icon_name (xcb_connection_t *c,
 	xcb_change_property(c, XCB_PROP_MODE_REPLACE, window, WM_ICON_NAME, encoding, 8, name_len, name);
 }
 
-int
-xcb_get_wm_icon_name (xcb_connection_t *c,
-                      xcb_window_t      window,
-                      uint8_t          *format,
-                      xcb_atom_t       *encoding,
-                      uint32_t         *name_len,
-                      char            **name)
+xcb_text_property_cookie_t
+xcb_get_wm_icon_name(xcb_connection_t *c,
+                     xcb_window_t window)
 {
-	return xcb_get_text_property(c, window, WM_ICON_NAME, format, encoding, name_len, name);
+  return xcb_get_text_property(c, window, WM_ICON_NAME);
 }
 
 void
@@ -142,15 +152,11 @@ xcb_set_wm_client_machine (xcb_connection_t *c,
 	xcb_change_property(c, XCB_PROP_MODE_REPLACE, window, WM_CLIENT_MACHINE, encoding, 8, name_len, name);
 }
 
-int
+xcb_text_property_cookie_t
 xcb_get_wm_client_machine (xcb_connection_t *c,
-                           xcb_window_t      window,
-                           uint8_t          *format,
-                           xcb_atom_t       *encoding,
-                           uint32_t         *name_len,
-                           char            **name)
+                           xcb_window_t window)
 {
-	return xcb_get_text_property(c, window, WM_CLIENT_MACHINE, format, encoding, name_len, name);
+  return xcb_get_text_property(c, window, WM_CLIENT_MACHINE);
 }
 
 void
diff --git a/icccm/xcb_icccm.h b/icccm/xcb_icccm.h
index 337b726..a27c50e 100644
--- a/icccm/xcb_icccm.h
+++ b/icccm/xcb_icccm.h
@@ -4,18 +4,32 @@
 #include <xcb/xcb.h>
 #include "xcb_property.h"
 
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-int  xcb_get_text_property (xcb_connection_t *c,
-                            xcb_window_t     window,
-                            xcb_atom_t       property,
-                            uint8_t          *format,
-                            xcb_atom_t       *encoding,
-                            uint32_t         *name_len,
-                            char             **name);
+typedef xcb_get_property_cookie_t xcb_text_property_cookie_t;
+
+typedef struct {
+  uint8_t format;
+  xcb_atom_t encoding;
+  uint32_t name_len;
+  char *name;
+} xcb_text_property_t;
+
+xcb_text_property_cookie_t 
+xcb_get_text_property(xcb_connection_t *c,
+                      xcb_window_t window,
+                      xcb_atom_t property);
+
+xcb_text_property_cookie_t
+xcb_get_text_property_unchecked(xcb_connection_t *c,
+                                xcb_window_t window,
+                                xcb_atom_t property);
+xcb_text_property_t *
+xcb_get_text_property_reply(xcb_connection_t *c,
+                            xcb_get_property_cookie_t cookie,
+                            xcb_generic_error_t **e);
 
 /* WM_NAME */
 
@@ -31,12 +45,8 @@ void xcb_set_wm_name (xcb_connection_t *c,
                       uint32_t          name_len,
                       const char       *name);
 
-int  xcb_get_wm_name (xcb_connection_t *c,
-                      xcb_window_t      window,
-                      uint8_t          *format,
-                      xcb_atom_t       *encoding,
-                      uint32_t         *name_len,
-                      char            **name);
+xcb_text_property_cookie_t xcb_get_wm_name(xcb_connection_t *c,
+                                           xcb_window_t      window);
 
 void xcb_watch_wm_name (xcb_property_handlers_t        *prophs,
                         uint32_t                       long_len,
@@ -57,12 +67,8 @@ void xcb_set_wm_icon_name (xcb_connection_t *c,
                            uint32_t          name_len,
                            const char       *name);
 
-int  xcb_get_wm_icon_name (xcb_connection_t *c,
-                           xcb_window_t      window,
-                           uint8_t          *format,
-                           xcb_atom_t       *encoding,
-                           uint32_t         *name_len,
-                           char            **name);
+xcb_text_property_cookie_t xcb_get_wm_icon_name (xcb_connection_t *c,
+                                                 xcb_window_t window);
 
 void xcb_watch_wm_icon_name (xcb_property_handlers_t        *prophs,
                              uint32_t                       long_len,
@@ -83,12 +89,8 @@ void xcb_set_wm_client_machine (xcb_connection_t *c,
                                 uint32_t          name_len,
                                 const char       *name);
 
-int  xcb_get_wm_client_machine (xcb_connection_t *c,
-                                xcb_window_t      window,
-                                uint8_t          *format,
-                                xcb_atom_t       *encoding,
-                                uint32_t         *name_len,
-                                char            **name);
+xcb_text_property_cookie_t xcb_get_wm_client_machine (xcb_connection_t *c,
+                                                      xcb_window_t window);
 
 void xcb_watch_wm_client_machine (xcb_property_handlers_t        *prophs,
                                   uint32_t                       long_len,

