fix bug 1057012, 1079882

Replaces #2778
stuck?