fixed various Xlib and layout bugs