Refactor the templates a little bit