Fixed bug in rewrite function that would cause process to hang if thread creation failed.
Fixed bug in rewrite function that would cause
process to hang if thread creation failed.

kev40293/NoVoHT,kev40293/NoVoHT,kev40293/NoVoHT,kev40293/NoVoHT