Windows fixes

Visual Studio is very particular about ``c`` vs ``cpp`` files. It's also much more strict about certain kinds of casting.