Fix bug with incorrect cache reuse