Rewrite for fix crash on windows.