Fix bugs in topology_cache.c.