Further refactoring, removed most javascript from html page.