Fix compile cast warnings present in VS

The wiki asserts that there are no compile time warnings, but there are a few present in VS builds. This patch fixes those.