Cleanup and implemented for XLIB.