Windows Fixes

OK, to be a good boy I have remade this pull request and squashed my horrible work-in-progress commits. Here is a set of commits that makes more sense.

Most importantly, this needs to be checked by @nontas to make sure that HOGs still work as expected, as I made a few changes to floor/ceil/round calls for windows!