Bug fix to do with templates and 500/404 handling