Fixed a serious bug which is causing crash on windows