Replaced mixed html/php in several functions, using Html::element functions to replace emitting raw HTML.