Broke doIdle function into two separate functions each of which are simpler than the combined one. Minor cleanup and comments in GlobalIdle.