OSX and Linux compatibility fixes

This pull request fixes compilation issues when building Linux packages and also makes current master build fine on OSX 64bit.