diff --git a/ClassCollectionLoader.php b/ClassCollectionLoader.php
index <HASH>..<HASH> 100644
--- a/ClassCollectionLoader.php
+++ b/ClassCollectionLoader.php
@@ -116,8 +116,8 @@ class ClassCollectionLoader
         }
 
         // cache the core classes
-        if (!is_dir(dirname($cache))) {
-            mkdir(dirname($cache), 0777, true);
+        if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
+            throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir));
         }
         self::writeCacheFile($cache, '<?php '.$content);
 
diff --git a/ClassMapGenerator.php b/ClassMapGenerator.php
index <HASH>..<HASH> 100644
--- a/ClassMapGenerator.php
+++ b/ClassMapGenerator.php
@@ -134,7 +134,7 @@ class ClassMapGenerator
                     }
 
                     if ($isClassConstant) {
-                        continue;
+                        break;
                     }
 
                     // Find the classname
[<I>] Static Code Analysis for Components