Fixed memory corruption on windows