Simplify has_*_perm functions and improve speed