Resolve some MS compiler warnings (in picky mode)

Example compiler messages with /W4 flag: VC8, VC9, VC10, VC11 (VS 2005, 2008, 2010, 2012)

warning C4267: 'argument' : conversion from 'size_t' to 'DWORD', possible loss of data
warning C4800: 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
warning C4244: 'return' : conversion from 'double' to 'int', possible loss of data