Import X11 and Win32 code changed by Harrison