First working version (with bugs, but generating the html code).