Dealing with some compilers discrepancies

Some additional casting was performed to compile on Windows (with cl
compiler) Tested on Visual Studio 2010