Fixes to allow compilation on mac os x (tested on Mavericks 10.9)