Re-work idle handling from previous commit.