Improved permission handling.