Thanks Thomas Güttler for the suggestion. Backport of 28acc0d6df844ccfc8de6f4e7d5883eb4841e946 from master