Restructure code

Move the creation of a root item from the view into the form.