fix gcc 4.7 build
more tweaks to get it working on OSX