Some minor refactoring, and clarification
Refactoring of HTML-munging code.