fixed a bug in cache, it did not free unused cubes