Refactor prefix cache