Cleanup. using templates, moved stuff to view