Replaced permissions handling code