Adding cookies, better structure and error handling of pages