move render_template to functions, fix concordance_from_collocation, and many other fixes