various fixes of code

small fixes of code and changes to enable compilation on Mac OS X