diff --git a/libraries.module b/libraries.module
index 2255b4a..366d775 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 (isset($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.
@@ -292,6 +350,10 @@ function libraries_info_defaults(&$library, $name) {
     'post-detect' => array(),
     'load' => array(),
   );
+  
+  // Add our own callbacks before any others.
+  $library['callbacks']['info'] = array_merge(array('libraries_prepare_files'), $library['callbacks']['info']);
+  
   return $library;
 }
 
@@ -548,7 +610,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 d70a10e..bdee7f3 100644
--- a/tests/libraries.test
+++ b/tests/libraries.test
@@ -31,6 +31,24 @@ class LibrariesTestCase extends DrupalWebTestCase {
   function testLibraries() {
     // Test libraries_get_path().
     $this->assertEqual(libraries_get_path('example'), FALSE, 'libraries_get_path() returns FALSE for a missing library.');
+    
+    // Test libraries_prepare_files().
+    $expected = array(
+      'files' => array(
+        'js' => array('example.js' => array()),
+        'css' => array('example.css' => array()),
+        'php' => array('example.php' => array()),
+      ),
+    );
+    $library = array(
+      'files' => array(
+        'js' => array('example.js'),
+        'css' => array('example.css'),
+        'php' => array('example.php'),
+      ),
+    );
+    libraries_prepare_files($library, NULL, NULL);
+    $this->assertEqual($expected, $library, 'libraries_prepare_files() works correctly.');
 
     // Test that library information is found correctly.
     $expected = array(
@@ -38,9 +56,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()),
       ),
       'module' => 'libraries_test',
     );
@@ -107,9 +125,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('<pre>' . var_export($library, TRUE) . '</pre>');
     $this->assertEqual($library['files'], $files, 'Top-level files property works.');
@@ -117,9 +135,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('<pre>' . var_export($library, TRUE) . '</pre>');
     $this->assertEqual($library['files'], $files, 'Version-specific library files found.');
