diff --git a/libraries.module b/libraries.module
index 192a052..194f135 100644
--- a/libraries.module
+++ b/libraries.module
@@ -204,6 +204,64 @@ function libraries_traverse_library(&$library, $callback) {
 }
 
 /**
+* Helper callback to make 'files' property of libraries consistent.
+*
+* This turns libraries' file information declared as e.g.
+* @code
+* $library['files']['js'] = array('example_1.js', 'example_2.js');
+* @endcode
+* into
+* @code
+* $library['files']['js'] = array(
+*   'example_1.js' => array(),
+*   'example_2.js' => array(),
+* );
+* @endcode
+* It does the same for the 'integration files' property.
+*
+* @param $library
+*   An associative array of library information or a part of it, passed by
+*   reference.
+* @param $version
+*   If the library information belongs to a specific version, the version
+*   string. NULL otherwise.
+* @param $variant
+*   If the library information belongs to a specific variant, the variant name.
+*   NULL otherwise.
+*
+* @see libraries_info()
+* @see libraries_invoke()
+*/
+function libraries_prepare_files(&$library, $version, $variant) {
+  // Both the 'files' property and the 'integration files' property contain file
+  // declarations, and we want to make both consistent.
+  $file_types = array();
+  if (isset($library['files'])) {
+    $file_types[] = &$library['files'];
+  }
+  if (isset($library['integration files'])) {
+    // Integration files are additionally keyed by module.
+    foreach ($library['integration files'] as &$integration_files) {
+      $file_types[] = &$integration_files;
+    }
+  }
+  foreach ($file_types as &$files) {
+    // Go through all supported types of files.
+    foreach (array('js', 'css', 'php') as $type) {
+      if (!empty($files[$type])) {
+        foreach ($files[$type] as $key => $value) {
+          // Unset numeric keys and turn the respective values into keys.
+          if (is_numeric($key)) {
+            $files[$type][$value] = array();
+            unset($files[$type][$key]);
+          }
+        }
+      }
+    }
+  }
+}
+
+/**
  * Returns information about registered libraries.
  *
  * The returned information is unprocessed, i.e. as registered by modules.
@@ -264,6 +322,9 @@ function libraries_info($name = NULL) {
         'detect' => array(),
         'load' => array(),
       );
+
+      // Add libraries' callbacks before any other callbacks.
+      $properties['callbacks']['prepare'] = array_merge(array('libraries_prepare_files'), $properties['callbacks']['prepare']);
     }
 
     // Allow modules to alter the registered libraries.
@@ -531,7 +592,7 @@ function libraries_load_files($library) {
 
   // Load PHP files.
   if (!empty($library['files']['php'])) {
-    foreach ($library['files']['php'] as $file) {
+    foreach ($library['files']['php'] as $file => $array) {
       $file_path = DRUPAL_ROOT . '/' . $path . '/' . $file;
       if (file_exists($file_path)) {
         require_once $file_path;
diff --git a/tests/libraries.test b/tests/libraries.test
index b9521ef..d835710 100644
--- a/tests/libraries.test
+++ b/tests/libraries.test
@@ -39,9 +39,9 @@ class LibrariesTestCase extends DrupalWebTestCase {
       'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
       'version' => '1',
       'files' => array(
-        'js' => array('example_1.js'),
-        'css' => array('example_1.css'),
-        'php' => array('example_1.php'),
+        'js' => array('example_1.js' => array()),
+        'css' => array('example_1.css' => array()),
+        'php' => array('example_1.php' => array()),
       ),
     ));
     $library = libraries_info('example_files');
@@ -107,9 +107,9 @@ class LibrariesTestCase extends DrupalWebTestCase {
     // Test a top-level files property.
     $library = libraries_detect('example_files');
     $files = array(
-      'js' => array('example_1.js'),
-      'css' => array('example_1.css'),
-      'php' => array('example_1.php'),
+      'js' => array('example_1.js' => array()),
+      'css' => array('example_1.css' => array()),
+      'php' => array('example_1.php' => array()),
     );
     $this->verbose(var_export($library, TRUE));
     $this->assertEqual($library['files'], $files, 'Top-level files property works.');
@@ -117,9 +117,9 @@ class LibrariesTestCase extends DrupalWebTestCase {
     // Test version-specific library files.
     $library = libraries_detect('example_versions');
     $files = array(
-      'js' => array('example_2.js'),
-      'css' => array('example_2.css'),
-      'php' => array('example_2.php'),
+      'js' => array('example_2.js' => array()),
+      'css' => array('example_2.css' => array()),
+      'php' => array('example_2.php' => array()),
     );
     $this->verbose(var_export($library, TRUE));
     $this->assertEqual($library['files'], $files, 'Version-specific library files found.');
@@ -168,7 +168,7 @@ class LibrariesTestCase extends DrupalWebTestCase {
         ),
       ),
       'callbacks' => array(
-        'prepare' => array('_libraries_test_prepare_callback'),
+        'prepare' => array('libraries_prepare_files', '_libraries_test_prepare_callback'),
         'detect' => array('_libraries_test_detect_callback'),
         'load' => array('_libraries_test_load_callback'),
       ),
@@ -182,8 +182,8 @@ class LibrariesTestCase extends DrupalWebTestCase {
     $expected['versions']['1']['variants']['example_variant']['prepare callback'] = 'applied (version 1, variant example_variant)';
     $expected['variants']['example_variant']['prepare callback'] = 'applied (variant example_variant)';
     $library = libraries_info('example_callback');
-    $this->verbose(var_export($expected, TRUE));
-    $this->verbose(var_export($library, TRUE));
+    $this->verbose('<pre>' . var_export($expected, TRUE) . '</pre>');
+    $this->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
     $this->assertEqual($library, $expected, 'Prepare callback was applied correctly.');
     // Test a callback in the 'detect' phase.
     unset($expected['versions']);
