Adding all structures and finishing *allocate_cache function.