re-implemented basic template rendering, still needs a lot of work