Added a small sleep after every isDone check.

I also did the change on your CodeCleanup branch. I wasn't sure where you wanted it.