Improve cache handling