Fixes for Mac OS X and Linux compilation

This one provenly compiles both under Mac OS X and Linux, and works also on older versions (10.6, 10.7) of Mac OS X.