Fix bug 2079 (with corrections)