Further improvements to HTMRL, cleaned up code.