Fixed undefined variable issues in cache logic.
Merge pull request #31 from Rarst/cache-var-logic

Fixed undefined variable issues in cache logic.