diff --git a/storm.module b/storm.module
index e188def..a12b6d6 100644
--- a/storm.module
+++ b/storm.module
@@ -140,7 +140,7 @@ function storm_dashboard() {
 function storm_admin_settings() {
   $form = array();
   $w = -10;
-  
+
   $form['icons'] = array(
     '#type' => 'fieldset',
     '#title' => t('Icons'),
@@ -156,15 +156,16 @@ function storm_admin_settings() {
     '#description' => t('The icons that ship with Storm may not fit well with some themes. If this box is unchecked, icons will be hidden.'),
     '#weight' => $w++,
   );
-  
+
   $form['icons']['storm_icons_path'] = array(
     '#type' => 'textfield',
     '#title' => t('Icons directory'),
     '#default_value' => variable_get('storm_icons_path', drupal_get_path('module', 'storm') .'/icons'),
     '#description' => t("The directory that contains Storm's icons."),
     '#weight' => $w++,
+    '#element_validate' => array('storm_admin_settings_icons_path_validate'),
   );
-  
+
   $form['lists'] = array(
     '#type' => 'fieldset',
     '#title' => t('Lists'),
@@ -324,6 +325,25 @@ function storm_admin_settings() {
   return system_settings_form($form);
 }
 
+/**
+ * Validate Icon Path form element.
+ *
+ * @param $form
+ * @param $form_values
+ */
+function storm_admin_settings_icons_path_validate($form, $form_values) {
+  $icon_path_old = variable_get('storm_icons_path', drupal_get_path('module', 'storm') .'/icons');
+  $icon_path = $form_values['values']['storm_icons_path'];
+  // check if directory exists
+  if (!is_dir($icon_path)) {
+    form_set_error('storm_icons_path', t('Icon path %path does not exist', array('%path' => $icon_path)));
+  }
+  // if it exists and changed, delete cache, so there are no old values in the cache
+  elseif ($icon_path != $icon_path_old) {
+    cache_clear_all('storm:icons', 'cache', FALSE);
+  }
+}
+
 // DATE / TIME MANIPULATION
 function storm_elements() {
   $type['datetime'] = array(
@@ -797,9 +817,10 @@ function storm_icon_recache() {
 
   // For PHP5, replace with scandir() function
   $dir = variable_get('storm_icons_path', drupal_get_path('module', 'storm'). '/icons');
-  $dh = opendir($dir);
-  while (false !== ($filename = readdir($dh))) {
-    $available[] = $filename;
+
+  $files = file_scan_directory($dir, '.*');
+  foreach ($files as $file) {
+    $available[] = $file->basename;
   }
 
   cache_set('storm:icons', $available, 'cache', CACHE_TEMPORARY);
