Ui

Moved main functions to the top. Changed layout of the html doc.