Misc cleanup.

- Changes to make code compiler on MSVC
- Changes that make the code actually c++ standards
  compliant.