[Refactoring] around protection code fixed in the PR #3651

Tweak code style, slim up code logic, and a trivial bug fix.

@Dicebot I found two questions while refactoring.

1. How `__traite(getProtection)` should print the new protection `package(names)`?
2. How should the JSON property `protection` print `package(names)`?