Lot of workarounds and a fix (flat + layout qualifier) for MacOSX