Fix bug and cache with static initialization