Cleanup of HTML generation code