From https://drupal.org/node/1108164