Reworked the cache implementation, as the previous definition was just a work in process