Improve no permission handling, fix npe