infinite loop errors fixed (cherry-picked from 3.3 refs #4706)