Permissions and js bug fix