Updated automatic permission gen code