clean up templates and add error pages