Ported the Xlib nightmare