Fixed couple bugs in cache control