adding comments to the functions in the html class, also some modest refactoring