fix error handling on pages, some template fixing