Fixing parts of: https://www.drupal.org/node/2327711