Various fixes and first version of HTML generation