Fix for bug 1022370, 1023207