Fixed a mutex leak.
Fixed NULL pointer dereference bug.
Minor performance improvement.
Fixed erroneous check for CreateFileMapping success. CreateFileMapping returns NULL on error.