Templating

 - Use the twig templating engine to separate PHP and HTML code
 - Various minor fixes