Added some JS, tided up some templates