Fixed permission bugs