Fix record_heads by using cache.