Templating from the frontend and various major bugfixes