Added changes to match https://drupal.org/comment/6977126#comment-6977126