Minor fixes to attempt to fix infinite loops.