Cleaned up permissions check.