Refactored creating permissions cache