minor fixes and better templating system