by Kuba Ober: changes to compile under MacOS and Win32 MSVC