Update permissions and fix bugs