Parameterize main loop constants and document.