backporting changes while attempting to build on windows:

pulled in one change from d05b650bc7355d2afc96d910806827305c9d46f6