Changed permission checking.