added checks for 404 and permissions
Merge origin/master
added checks for 404 and permissions