Fixes to if statements within while loops.