Improved permission query.