Merge "Ensure permissions are revoked on state changes"