Improve cache functions