Refactor.
Fix cache bug.