Readded fix from changeset 9e0d60 to master wrongfuly removed in changeset df00b2