Fix for bugs #2878, #2879