Some tweaks to build on OS X and Linux

Hi, I've made some simple changes to build on Mac OSX and Linux. It shouldn't have broken anything on WIN32, but I don't have a Windows box to verify. 
Can you consider to pull?

Bye,
Andrea.