Check state changes before going into enless loops

Original commit message from CVS:
Check state changes before going into enless loops
2 files changed