Main loop: sleep 1 only if not about to quit.
Don't sleep unnecessarily in batch submit.
Code batch submit thread loop a bit better.
Merge pull request #714 from hjoliver/minor-code-loop-improvements

Minor code loop improvements