Fixes for D.O. issues #2174453 and #1998848

Fixes for issues:

- https://drupal.org/node/1998848
- https://drupal.org/node/2174453