Patch from http://drupal.org/comment/7799369#comment-7799369