fixed some templating bugs + improved routing