diff --git a/magick/cache.c b/magick/cache.c
index e7a3f5d..cbb7321 100644
--- a/magick/cache.c
+++ b/magick/cache.c
@@ -203,7 +203,8 @@
   if ((cache_resources == (SplayTreeInfo *) NULL) &&
       (instantiate_cache == MagickFalse))
     {
-      AcquireSemaphoreInfo(&cache_semaphore);
+      if (cache_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&cache_semaphore);
       LockSemaphoreInfo(cache_semaphore);
       if ((cache_resources == (SplayTreeInfo *) NULL) &&
           (instantiate_cache == MagickFalse))
diff --git a/magick/coder.c b/magick/coder.c
index bdb8ad1..264ac74 100644
--- a/magick/coder.c
+++ b/magick/coder.c
@@ -532,7 +532,8 @@
   if ((coder_list == (SplayTreeInfo *) NULL) &&
       (instantiate_coder == MagickFalse))
     {
-      AcquireSemaphoreInfo(&coder_semaphore);
+      if (coder_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&coder_semaphore);
       LockSemaphoreInfo(coder_semaphore);
       if ((coder_list == (SplayTreeInfo *) NULL) &&
           (instantiate_coder == MagickFalse))
diff --git a/magick/color.c b/magick/color.c
index a6926ee..ca6fb01 100644
--- a/magick/color.c
+++ b/magick/color.c
@@ -1456,7 +1456,8 @@
   if ((color_list == (LinkedListInfo *) NULL) &&
       (instantiate_color == MagickFalse))
     {
-      AcquireSemaphoreInfo(&color_semaphore);
+      if (color_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&color_semaphore);
       LockSemaphoreInfo(color_semaphore);
       if ((color_list == (LinkedListInfo *) NULL) &&
           (instantiate_color == MagickFalse))
diff --git a/magick/configure.c b/magick/configure.c
index eb89731..c4c569c 100644
--- a/magick/configure.c
+++ b/magick/configure.c
@@ -868,7 +868,8 @@
   if ((configure_list == (LinkedListInfo *) NULL) &&
       (instantiate_configure == MagickFalse))
     {
-      AcquireSemaphoreInfo(&configure_semaphore);
+      if (configure_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&configure_semaphore);
       LockSemaphoreInfo(configure_semaphore);
       if ((configure_list == (LinkedListInfo *) NULL) &&
           (instantiate_configure == MagickFalse))
diff --git a/magick/constitute.c b/magick/constitute.c
index 12f74f7..6473319 100644
--- a/magick/constitute.c
+++ b/magick/constitute.c
@@ -510,15 +510,14 @@
       image=DestroyImage(image);
     }
   image=NewImageList();
+  if (constitute_semaphore == (SemaphoreInfo *) NULL)
+    AcquireSemaphoreInfo(&constitute_semaphore);
   if ((magick_info != (const MagickInfo *) NULL) &&
       (GetImageDecoder(magick_info) != (DecodeImageHandler *) NULL))
     {
       thread_support=GetMagickThreadSupport(magick_info);
       if ((thread_support & DecoderThreadSupport) == 0)
-        {
-          AcquireSemaphoreInfo(&constitute_semaphore);
-          LockSemaphoreInfo(constitute_semaphore);
-        }
+        LockSemaphoreInfo(constitute_semaphore);
       image=GetImageDecoder(magick_info)(read_info,exception);
       if ((thread_support & DecoderThreadSupport) == 0)
         UnlockSemaphoreInfo(constitute_semaphore);
@@ -550,10 +549,7 @@
         MaxTextExtent);
       *read_info->filename='\0';
       if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
-        {
-          AcquireSemaphoreInfo(&constitute_semaphore);
-          LockSemaphoreInfo(constitute_semaphore);
-        }
+        LockSemaphoreInfo(constitute_semaphore);
       (void) InvokeDelegate(read_info,image,read_info->magick,(char *) NULL,
         exception);
       if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
@@ -577,10 +573,7 @@
         }
       thread_support=GetMagickThreadSupport(magick_info);
       if ((thread_support & DecoderThreadSupport) == 0)
-        {
-          AcquireSemaphoreInfo(&constitute_semaphore);
-          LockSemaphoreInfo(constitute_semaphore);
-        }
+        LockSemaphoreInfo(constitute_semaphore);
       image=(Image *) (GetImageDecoder(magick_info))(read_info,exception);
       if ((thread_support & DecoderThreadSupport) == 0)
         UnlockSemaphoreInfo(constitute_semaphore);
@@ -1101,6 +1094,8 @@
           (void) CloseBlob(image);
         }
     }
+  if (constitute_semaphore == (SemaphoreInfo *) NULL)
+    AcquireSemaphoreInfo(&constitute_semaphore);
   if ((magick_info != (const MagickInfo *) NULL) &&
       (GetImageEncoder(magick_info) != (EncodeImageHandler *) NULL))
     {
@@ -1109,10 +1104,7 @@
       */
       thread_support=GetMagickThreadSupport(magick_info);
       if ((thread_support & EncoderThreadSupport) == 0)
-        {
-          AcquireSemaphoreInfo(&constitute_semaphore);
-          LockSemaphoreInfo(constitute_semaphore);
-        }
+        LockSemaphoreInfo(constitute_semaphore);
       status=GetImageEncoder(magick_info)(write_info,image);
       if ((thread_support & EncoderThreadSupport) == 0)
         UnlockSemaphoreInfo(constitute_semaphore);
@@ -1128,10 +1120,7 @@
           */
           *write_info->filename='\0';
           if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
-            {
-              AcquireSemaphoreInfo(&constitute_semaphore);
-              LockSemaphoreInfo(constitute_semaphore);
-            }
+            LockSemaphoreInfo(constitute_semaphore);
           status=InvokeDelegate(write_info,image,(char *) NULL,
             write_info->magick,&image->exception);
           if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
@@ -1162,10 +1151,7 @@
               */
               thread_support=GetMagickThreadSupport(magick_info);
               if ((thread_support & EncoderThreadSupport) == 0)
-                {
-                  AcquireSemaphoreInfo(&constitute_semaphore);
-                  LockSemaphoreInfo(constitute_semaphore);
-                }
+                LockSemaphoreInfo(constitute_semaphore);
               status=GetImageEncoder(magick_info)(write_info,image);
               if ((thread_support & EncoderThreadSupport) == 0)
                 UnlockSemaphoreInfo(constitute_semaphore);
diff --git a/magick/delegate.c b/magick/delegate.c
index 9706f2d..3171f13 100644
--- a/magick/delegate.c
+++ b/magick/delegate.c
@@ -708,7 +708,8 @@
   if ((delegate_list == (LinkedListInfo *) NULL) &&
       (instantiate_delegate == MagickFalse))
     {
-      AcquireSemaphoreInfo(&delegate_semaphore);
+      if (delegate_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&delegate_semaphore);
       LockSemaphoreInfo(delegate_semaphore);
       if ((delegate_list == (LinkedListInfo *) NULL) &&
           (instantiate_delegate == MagickFalse))
diff --git a/magick/locale.c b/magick/locale.c
index cf4dda9..a10559b 100644
--- a/magick/locale.c
+++ b/magick/locale.c
@@ -549,7 +549,8 @@
   if ((locale_list == (SplayTreeInfo *) NULL) &&
       (instantiate_locale == MagickFalse))
     {
-      AcquireSemaphoreInfo(&locale_semaphore);
+      if (locale_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&locale_semaphore);
       LockSemaphoreInfo(locale_semaphore);
       if ((locale_list == (SplayTreeInfo *) NULL) &&
           (instantiate_locale == MagickFalse))
diff --git a/magick/log.c b/magick/log.c
index dad845b..677fe21 100644
--- a/magick/log.c
+++ b/magick/log.c
@@ -530,7 +530,8 @@
 {
   if ((log_list == (LinkedListInfo *) NULL) && (instantiate_log == MagickFalse))
     {
-      AcquireSemaphoreInfo(&log_semaphore);
+      if (log_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&log_semaphore);
       LockSemaphoreInfo(log_semaphore);
       if ((log_list == (LinkedListInfo *) NULL) &&
           (instantiate_log == MagickFalse))
diff --git a/magick/magic.c b/magick/magic.c
index 83f290a..74b3902 100644
--- a/magick/magic.c
+++ b/magick/magic.c
@@ -522,7 +522,8 @@
   if ((magic_list == (LinkedListInfo *) NULL) &&
       (instantiate_magic == MagickFalse))
     {
-      AcquireSemaphoreInfo(&magic_semaphore);
+      if (magic_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&magic_semaphore);
       LockSemaphoreInfo(magic_semaphore);
       if ((magic_list == (LinkedListInfo *) NULL) &&
           (instantiate_magic == MagickFalse))
diff --git a/magick/magick.c b/magick/magick.c
index 4ea2961..9e6828b 100644
--- a/magick/magick.c
+++ b/magick/magick.c
@@ -775,7 +775,8 @@
   if ((magick_list == (SplayTreeInfo *) NULL) &&
       (instantiate_magick == MagickFalse))
     {
-      AcquireSemaphoreInfo(&magick_semaphore);
+      if (magick_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&magick_semaphore);
       LockSemaphoreInfo(magick_semaphore);
       if ((magick_list == (SplayTreeInfo *) NULL) &&
           (instantiate_magick == MagickFalse))
diff --git a/magick/mime.c b/magick/mime.c
index c53b684..f472d21 100644
--- a/magick/mime.c
+++ b/magick/mime.c
@@ -604,7 +604,8 @@
   if ((mime_list == (LinkedListInfo *) NULL) &&
       (instantiate_mime == MagickFalse))
     {
-      AcquireSemaphoreInfo(&mime_semaphore);
+      if (mime_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&mime_semaphore);
       LockSemaphoreInfo(mime_semaphore);
       if ((mime_list == (LinkedListInfo *) NULL) &&
           (instantiate_mime == MagickFalse))
diff --git a/magick/module.c b/magick/module.c
index ef3785c..2d4d221 100644
--- a/magick/module.c
+++ b/magick/module.c
@@ -847,7 +847,8 @@
   if ((module_list == (SplayTreeInfo *) NULL) &&
       (instantiate_module == MagickFalse))
     {
-      AcquireSemaphoreInfo(&module_semaphore);
+      if (module_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&module_semaphore);
       LockSemaphoreInfo(module_semaphore);
       if ((module_list == (SplayTreeInfo *) NULL) &&
           (instantiate_module == MagickFalse))
diff --git a/magick/policy.c b/magick/policy.c
index 0a1d997..eb6c104 100644
--- a/magick/policy.c
+++ b/magick/policy.c
@@ -428,7 +428,8 @@
   if ((policy_list == (LinkedListInfo *) NULL) &&
       (instantiate_policy == MagickFalse))
     {
-      AcquireSemaphoreInfo(&policy_semaphore);
+      if (policy_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&policy_semaphore);
       LockSemaphoreInfo(policy_semaphore);
       if ((policy_list == (LinkedListInfo *) NULL) &&
           (instantiate_policy == MagickFalse))
diff --git a/magick/registry.c b/magick/registry.c
index c69ef5e..5971965 100644
--- a/magick/registry.c
+++ b/magick/registry.c
@@ -525,7 +525,8 @@
   if ((registry == (SplayTreeInfo *) NULL) &&
       (instantiate_registry == MagickFalse))
     {
-      AcquireSemaphoreInfo(&registry_semaphore);
+      if (registry_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&registry_semaphore);
       LockSemaphoreInfo(registry_semaphore);
       if ((registry == (SplayTreeInfo *) NULL) &&
           (instantiate_registry == MagickFalse))
diff --git a/magick/type.c b/magick/type.c
index c08c425..fde0b64 100644
--- a/magick/type.c
+++ b/magick/type.c
@@ -771,7 +771,8 @@
   if ((type_list == (SplayTreeInfo *) NULL) &&
       (instantiate_type == MagickFalse))
     {
-      AcquireSemaphoreInfo(&type_semaphore);
+      if (type_semaphore == (SemaphoreInfo *) NULL)
+        AcquireSemaphoreInfo(&type_semaphore);
       LockSemaphoreInfo(type_semaphore);
       if ((type_list == (SplayTreeInfo *) NULL) &&
           (instantiate_type == MagickFalse))
diff --git a/utilities/animate.c b/utilities/animate.c
index 99fb913..9a23b51 100644
--- a/utilities/animate.c
+++ b/utilities/animate.c
@@ -84,9 +84,6 @@
 
 int main(int argc,char **argv)
 {
-  char
-    *metadata;
-
   ExceptionInfo
     *exception;
 
@@ -99,11 +96,8 @@
   MagickCoreGenesis(*argv,MagickTrue);
   exception=AcquireExceptionInfo();
   image_info=AcquireImageInfo();
-  metadata=(char *) NULL;
   status=MagickCommandGenesis(image_info,AnimateImageCommand,argc,argv,
-    &metadata,exception);
-  if (metadata != (char *) NULL)
-    metadata=DestroyString(metadata);
+    (char **) NULL,exception);
   image_info=DestroyImageInfo(image_info);
   exception=DestroyExceptionInfo(exception);
   MagickCoreTerminus();
diff --git a/utilities/composite.c b/utilities/composite.c
index 1ca591f..7c883a9 100644
--- a/utilities/composite.c
+++ b/utilities/composite.c
@@ -59,9 +59,6 @@
 */
 int main(int argc,char **argv)
 {
-  char
-    *metadata;
-
   ExceptionInfo
     *exception;
 
@@ -74,11 +71,8 @@
   MagickCoreGenesis(*argv,MagickTrue);
   exception=AcquireExceptionInfo();
   image_info=AcquireImageInfo();
-  metadata=(char *) NULL;
   status=MagickCommandGenesis(image_info,CompositeImageCommand,argc,argv,
-    &metadata,exception);
-  if (metadata != (char *) NULL)
-    metadata=DestroyString(metadata);
+    (char **) NULL,exception);
   image_info=DestroyImageInfo(image_info);
   exception=DestroyExceptionInfo(exception);
   MagickCoreTerminus();
diff --git a/utilities/conjure.c b/utilities/conjure.c
index bd591e5..8d020b8 100644
--- a/utilities/conjure.c
+++ b/utilities/conjure.c
@@ -78,9 +78,6 @@
 */
 int main(int argc,char **argv)
 {
-  char
-    *metadata;
-
   ExceptionInfo
     *exception;
 
@@ -93,11 +90,8 @@
   MagickCoreGenesis(*argv,MagickTrue);
   exception=AcquireExceptionInfo();
   image_info=AcquireImageInfo();
-  metadata=(char *) NULL;
   status=MagickCommandGenesis(image_info,ConjureImageCommand,argc,argv,
-    &metadata,exception);
-  if (metadata != (char *) NULL)
-    metadata=DestroyString(metadata);
+    (char **) NULL,exception);
   image_info=DestroyImageInfo(image_info);
   exception=DestroyExceptionInfo(exception);
   MagickCoreTerminus();
diff --git a/utilities/convert.c b/utilities/convert.c
index 34788f4..75c0a30 100644
--- a/utilities/convert.c
+++ b/utilities/convert.c
@@ -65,9 +65,6 @@
 */
 int main(int argc,char **argv)
 {
-  char
-    *metadata;
-
   ExceptionInfo
     *exception;
 
@@ -80,11 +77,8 @@
   MagickCoreGenesis(*argv,MagickTrue);
   exception=AcquireExceptionInfo();
   image_info=AcquireImageInfo();
-  metadata=(char *) NULL;
   status=MagickCommandGenesis(image_info,ConvertImageCommand,argc,argv,
-    &metadata,exception);
-  if (metadata != (char *) NULL)
-    metadata=DestroyString(metadata);
+    (char **) NULL,exception);
   image_info=DestroyImageInfo(image_info);
   exception=DestroyExceptionInfo(exception);
   MagickCoreTerminus();
diff --git a/utilities/display.c b/utilities/display.c
index c714c4e..468b770 100644
--- a/utilities/display.c
+++ b/utilities/display.c
@@ -89,9 +89,6 @@
 
 int main(int argc,char **argv)
 {
-  char
-    *metadata;
-
   ExceptionInfo
     *exception;
 
@@ -104,11 +101,8 @@
   MagickCoreGenesis(*argv,MagickTrue);
   exception=AcquireExceptionInfo();
   image_info=AcquireImageInfo();
-  metadata=(char *) NULL;
   status=MagickCommandGenesis(image_info,DisplayImageCommand,argc,argv,
-    &metadata,exception);
-  if (metadata != (char *) NULL)
-    metadata=DestroyString(metadata);
+    (char **) NULL,exception);
   image_info=DestroyImageInfo(image_info);
   exception=DestroyExceptionInfo(exception);
   MagickCoreTerminus();
diff --git a/utilities/import.c b/utilities/import.c
index c5d0c7f..e876a91 100644
--- a/utilities/import.c
+++ b/utilities/import.c
@@ -81,9 +81,6 @@
 
 int main(int argc,char **argv)
 {
-  char
-    *metadata;
-
   ExceptionInfo
     *exception;
 
@@ -96,11 +93,8 @@
   MagickCoreGenesis(*argv,MagickTrue);
   exception=AcquireExceptionInfo();
   image_info=AcquireImageInfo();
-  metadata=(char *) NULL;
   status=MagickCommandGenesis(image_info,ImportImageCommand,argc,argv,
-    &metadata,exception);
-  if (metadata != (char *) NULL)
-    metadata=DestroyString(metadata);
+    (char *) NULL,exception);
   image_info=DestroyImageInfo(image_info);
   exception=DestroyExceptionInfo(exception);
   MagickCoreTerminus();
diff --git a/utilities/mogrify.c b/utilities/mogrify.c
index 8476c1a..e933d90 100644
--- a/utilities/mogrify.c
+++ b/utilities/mogrify.c
@@ -61,9 +61,6 @@
 */
 int main(int argc,char **argv)
 {
-  char
-    *metadata;
-
   ExceptionInfo
     *exception;
 
@@ -76,11 +73,8 @@
   MagickCoreGenesis(*argv,MagickTrue);
   exception=AcquireExceptionInfo();
   image_info=AcquireImageInfo();
-  metadata=(char *) NULL;
   status=MagickCommandGenesis(image_info,ImportImageCommand,argc,argv,
-    &metadata,exception);
-  if (metadata != (char *) NULL)
-    metadata=DestroyString(metadata);
+    (char **) NULL,exception);
   image_info=DestroyImageInfo(image_info);
   exception=DestroyExceptionInfo(exception);
   MagickCoreTerminus();
diff --git a/utilities/montage.c b/utilities/montage.c
index a5ccbb1..5caa6af 100644
--- a/utilities/montage.c
+++ b/utilities/montage.c
@@ -61,9 +61,6 @@
 */
 int main(int argc,char **argv)
 {
-  char
-    *metadata;
-
   ExceptionInfo
     *exception;
 
@@ -76,11 +73,8 @@
   MagickCoreGenesis(*argv,MagickTrue);
   exception=AcquireExceptionInfo();
   image_info=AcquireImageInfo();
-  metadata=(char *) NULL;
   status=MagickCommandGenesis(image_info,MontageImageCommand,argc,argv,
-    &metadata,exception);
-  if (metadata != (char *) NULL)
-    metadata=DestroyString(metadata);
+    (char **) NULL,exception);
   image_info=DestroyImageInfo(image_info);
   exception=DestroyExceptionInfo(exception);
   MagickCoreTerminus();
diff --git a/utilities/stream.c b/utilities/stream.c
index dd5e56b..f50720a 100644
--- a/utilities/stream.c
+++ b/utilities/stream.c
@@ -61,9 +61,6 @@
 */
 int main(int argc,char **argv)
 {
-  char
-    *metadata;
-
   ExceptionInfo
     *exception;
 
@@ -76,11 +73,8 @@
   MagickCoreGenesis(*argv,MagickTrue);
   exception=AcquireExceptionInfo();
   image_info=AcquireImageInfo();
-  metadata=(char *) NULL;
   status=MagickCommandGenesis(image_info,StreamImageCommand,argc,argv,
-    &metadata,exception);
-  if (metadata != (char *) NULL)
-    metadata=DestroyString(metadata);
+    (char **) NULL,exception);
   image_info=DestroyImageInfo(image_info);
   exception=DestroyExceptionInfo(exception);
   MagickCoreTerminus();
diff --git a/wand/mogrify.c b/wand/mogrify.c
index 0ad5ccf..a29587b 100644
--- a/wand/mogrify.c
+++ b/wand/mogrify.c
@@ -182,7 +182,7 @@
               status=MagickTrue;
             CatchException(exception);
           }
-        if (*metadata != (char *) NULL)
+        if ((metadata != (char *) NULL) && (*metadata != (char *) NULL))
           {
             (void) fputs(*metadata,stdout);
             (void) fputc('\n',stdout);