Fix MSVC compiler warnings

- silenced narrowing conversion warnings with explicit casts
- fixed a warning about implicit conversion from int to bool by
  explicitly comparing to 0
- fixed a variable shadowing warning by removing an unused variable