Added permission validation and more informative ewrror messages