Bunch of Windows build & bug fixes from John Burnett