Msw fixup

The main commit in this PR is: 54c51ce which fixes a 32 bit int rollover bug. The other commits are small improvements on the way to actually fix the problem.