First pass over the codebase to make it compile under MSVC.
Self-review.