Replace CreateThread woth _beginthread so no CRT memory leaking.