Fixed windows threading bugs.