fixups for html
fixing some issues and general code cleanup. moving logic  out of html files
code cleanup