diff --git a/modules/ds_ui/includes/ds.fields.inc b/modules/ds_ui/includes/ds.fields.inc
index 051bbd6..1884639 100644
--- a/modules/ds_ui/includes/ds.fields.inc
+++ b/modules/ds_ui/includes/ds.fields.inc
@@ -193,12 +193,11 @@ function ds_shared_form(&$form, $field) {
 }
 
 /**
- * Element validation function for ui limit field
+ * Element validation function for ui limit field.
  */
 function ds_ui_limit_validate($element, &$form_state, $form) {
-  $entity_info = entity_get_info();
-  // Get all enabled entities
-  $entities = array_filter($form_state['values']['entities']);
+  // Get all enabled entity types.
+  $entity_types = array_filter($form_state['values']['entities']);
 
   if (!empty($element['#value'])) {
     $ui_limit = $element['#value'];
@@ -209,15 +208,15 @@ function ds_ui_limit_validate($element, &$form_state, $form) {
 
     $error = FALSE;
     foreach ($lines as $line) {
-      // Each line should hold a pipe character to seperate bundle and view_mode
-      if (strpos($line, '|') == FALSE) {
+      // Each line should hold a pipe character to seperate bundle and view_mode.
+      if (strpos($line, '|') === FALSE) {
         $error = TRUE;
         continue;
       }
 
       list($bundle, $view_mode) = explode('|', $line);
 
-      if (empty($bundle) || empty($view_mode) || !_ds_check_existing_ui_limit($entity_info, $entities, $bundle, $view_mode)) {
+      if (empty($bundle) || empty($view_mode) || !_ds_check_existing_ui_limit($entity_types, $bundle, $view_mode)) {
         $error = TRUE;
       }
     }
@@ -225,24 +224,24 @@ function ds_ui_limit_validate($element, &$form_state, $form) {
       form_error($element, t('The values are in the form of $bundle|$view_mode, where $view_mode may be either a view mode set to use custom settings, or \'default\'.'));
     }
 
-    // Set trimmed and validated entry back as value
+    // Set trimmed and validated entry back as value.
     form_set_value($element, implode("\n", $lines), $form_state);
   }
 }
 
 /**
- * Helper function to check if bundle + view_mode combination exists
+ * Helper function to check if bundle + view_mode combination exists.
  */
-function _ds_check_existing_ui_limit($entity_info, $entities, $bundle, $view_mode) {
+function _ds_check_existing_ui_limit($entity_types, $bundle, $view_mode) {
   $exists = FALSE;
-  foreach ($entities as $entity) {
-    $info = $entity_info[$entity];
+  foreach ($entity_types as $entity_type) {
+    $info = entity_get_info($entity_type);
 
-    // Combine allowed bundles and entity specific ones
+    // Combine allowed bundles and entity specific ones.
     $bundle_allowed = array('*');
     $bundles = array_merge($bundle_allowed, array_keys($info['bundles']));
 
-    // Combine allowed view_modes and entity specific ones
+    // Combine allowed view_modes and entity specific ones.
     $view_mode_allowed = array('*', 'default');
     $view_modes = array_merge($view_mode_allowed, array_keys($info['view modes']));
 
